JSP tricks to make templating easier?

As skaffman suggested, JSP 2.0 Tag Files are the bee’s knees. Let’s take your simple example. Put the following in WEB-INF/tags/wrapper.tag <%@tag description=”Simple Wrapper Tag” pageEncoding=”UTF-8″%> <html><body> <jsp:doBody/> </body></html> Now in your example.jsp page: <%@page contentType=”text/html” pageEncoding=”UTF-8″%> <%@taglib prefix=”t” tagdir=”/WEB-INF/tags” %> <t:wrapper> <h1>Welcome</h1> </t:wrapper> That does exactly what you think it does. So, lets expand … Read more

Can a class member function template be virtual?

Templates are all about the compiler generating code at compile-time. Virtual functions are all about the run-time system figuring out which function to call at run-time. Once the run-time system figured out it would need to call a templatized virtual function, compilation is all done and the compiler cannot generate the appropriate instance anymore. Therefore … Read more

How to dynamically change header based on AngularJS partial view?

I just discovered a nice way to set your page title if you’re using routing: JavaScript: var myApp = angular.module(‘myApp’, [‘ngResource’]) myApp.config( [‘$routeProvider’, function($routeProvider) { $routeProvider.when(“https://stackoverflow.com/”, { title: ‘Home’, templateUrl: ‘/Assets/Views/Home.html’, controller: ‘HomeController’ }); $routeProvider.when(‘/Product/:id’, { title: ‘Product’, templateUrl: ‘/Assets/Views/Product.html’, controller: ‘ProductController’ }); }]); myApp.run([‘$rootScope’, function($rootScope) { $rootScope.$on(‘$routeChangeSuccess’, function (event, current, previous) { $rootScope.title = … Read more

C++ template typedef

C++11 added alias declarations, which are generalization of typedef, allowing templates: template <size_t N> using Vector = Matrix<N, 1>; The type Vector<3> is equivalent to Matrix<3, 1>. In C++03, the closest approximation was: template <size_t N> struct Vector { typedef Matrix<N, 1> type; }; Here, the type Vector<3>::type is equivalent to Matrix<3, 1>.

Seeking useful Eclipse Java code templates [closed]

The following code templates will both create a logger and create the right imports, if needed. SLF4J ${:import(org.slf4j.Logger,org.slf4j.LoggerFactory)} private static final Logger LOG = LoggerFactory.getLogger(${enclosing_type}.class); Log4J 2 ${:import(org.apache.logging.log4j.LogManager,org.apache.logging.log4j.Logger)} private static final Logger LOG = LogManager.getLogger(${enclosing_type}.class); Log4J ${:import(org.apache.log4j.Logger)} private static final Logger LOG = Logger.getLogger(${enclosing_type}.class); Source. JUL ${:import(java.util.logging.Logger)} private static final Logger LOG = Logger.getLogger(${enclosing_type}.class.getName());

Templated check for the existence of a class member function?

Yes, with SFINAE you can check if a given class does provide a certain method. Here’s the working code: #include <iostream> struct Hello { int helloworld() { return 0; } }; struct Generic {}; // SFINAE test template <typename T> class has_helloworld { typedef char one; struct two { char x[2]; }; template <typename C> … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)