# | Description |
---|---|
NOTE: This is an example on how it can be done. | |
01 |
Your war file must import (including this one).
|
02 |
<servlet-mapping> <servlet-name>PropertyCollectionHandlingServlet</servlet-name> <url-pattern>/PropertyCollectionHandlingServlet</url-pattern> </servlet-mapping> |
03 |
@Override public void contextInitialized(ServletContextEvent context) { WebDemoProperties.getInstance(context.getServletContext()); } |
04 |
<listener> <listener-class>dk.heick.properties.webdemo.WebContext</listener-class> </listener> |
05 | Have two small images illustrates when a property is either valid or invalid. |
06 |
In your CSS definition make 3 new ones.
|
07 |
The handling URL "PropertyCollectionHandlingServlet" is a reference to the URL pattern defined above. Remember to take ServletContext into consideration. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <head> <link rel="stylesheet" type="text/css" href="css/stylesheet.css" title="Style"> </head> <BODY> <% WebDemoProperties collection = WebDemoProperties.getInstance(); String message = PropertyCollectionHandlingServlet.getCollectionMessage(request); PropertyCollectionRenderer render = new PropertyCollectionRenderer("images/valid.png","images/invalid.png","PropertyCollectionHandlingServlet"); PropertyIORenderer renderIO = PropertyIORenderer("PropertyCollectionHandlingServlet"); %> <h1>My Properties</h1> <% if (message!=null) { %> <b>Message:</b><%=message%><br/><br/> <% } %> <%=renderIO.renderPropertyIO(request, collection) %> <br/><br/> <%=render.renderProperties(request, collection,false) %> <br/><br/> <%=render.renderUnknownProperties(collection)%> </BODY> </HTML> |
08 |
|
09 |
To have a readonly version of this, you only need to setup bullets 01, 03, 04, 05, 06. And your JSP will look like: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <head> <link rel="stylesheet" type="text/css" href="css/stylesheet.css" title="Style"> </head> <BODY> <% WebDemoProperties collection = WebDemoProperties.getInstance(); PropertyCollectionRenderer render = new PropertyCollectionRenderer("images/valid.png","images/invalid.png"); PropertyIORenderer renderIO = PropertyIORenderer(); %> <h1>My Properties</h1> <% if (message!=null) { %> <b>Message:</b><%=message%><br/><br/> <% } %> <%=renderIO.renderPropertyIO(request, collection) %> <br/><br/> <%=render.renderProperties(request, collection,false) %> <br/><br/> <%=render.renderUnknownProperties(collection)%> </BODY> </HTML> |