span.ellipsis {
white-space:nowrap;
text-overflow:ellipsis;
overflow:hidden;
width:190px;
display:block;
}
auto truncate using CSS
dynamic menu selection using site mesh
one of the common features in the web applications is to highlight the menu item that corresponds to the current page so that users know where they are in the application.
here is how:
In decoratee, define the page’s menu information in meta data:
<head>
<meta name=”menu” content=”home” />
<meta name=”refreshInterval” content=”1″ />
</head>
In decorator, make sure to include the decoratee’s header and retrieve the value:
<html>
<head><decorator:head /></head>
…
<!– Script to select the active page’s button –>
<script>
//get the selected page’s menu
var selected = ‘<decorator:getProperty property=’meta.menu’ />’;
select(selected);
function select(buttonId) {
var myButton = document.getElementById(buttonId);
if(myButton != null) {
//change the button’s class to highlighted as defined in css
myButton.class=’highlightedMenu’;
}
}
</script>
<body>
…
<decorator:body />
</body>
Global exception / error handling in Spring framework
It’d be nice to have a common handler for exceptions so that each page in the web application does not have to worry about the exception handling at all.
Configure a bean in servlet context (APP-NAME-servlet.xml). errorPage is where it’ll be redirected to in the case of error. If the view resolver is set up in usual way, it’ll be WEB-INF/jsp/errorPage.jsp
<!– Basic Exception Resolver for webUI application –>
<bean id=”exceptionResolver”>
<property name=”exceptionMappings”>
<props>
<prop key=”java.lang.Exception”>errorPage</prop>
</props>
</property>
</bean>
In the jsp page, you can retrieve the exception from request parameter with the name “exception” and print as follows:
<% Throwable e = (Throwable)request.getAttribute(“exception”); %>
<%=e.toString() %>
Introduction to spring MVC and webflow
Good tutorial on getting starting with Spring concepts:
http://www.ervacon.com/products/swf/intro/index.html
This uses the spring 1x version; so some setup cofing and tag syntax are not applicable in 2x version. Nonetheless. it’s a good intro to spring tutorial.
Excellent one on Spring MVC config with webflow:
http://wheelersoftware.com/articles/spring-web-flow-2.0.html
Following the tutorial will give the higher level picture of how spring mvc and webflow plays in running a web application. Easy to follow and has sample resource files.