[jboss-user] [Tomcat, HTTPD, Servlets & JSP] - JSP, I18n and XML

dobbo do-not-reply at jboss.com
Mon Dec 10 16:36:36 EST 2007


Hi

I'm using XML based JSP files, and they are working well for me.  Somethings like this:

<jsp:root xmlns="http://www.w3c.org/1999/xhtml" 
  |           xmlns:jsp="http://java.sun.com/JSP/Page"
  |           xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
  |           xmlns:h="http://java.sun.com/jsf/html"
  |           xmlns:c="http://java.sun.com/jsp/jstl/core"
  |           version="2.0">
  |   <jsp:useBean
  |       id="editor"
  |       class="my.path.Editor"
  |       scope="request"/>
  |   <fmt:bundle basename="my.path.Messages">
  |      <form method="submit/form.jsp">
  |        <frameset>
  |           <legend><fmt:message key="legend.label"/></legend>
  |           <c:forEach var="code" items="${editor.columnCodes}">
  |             <input id="code-${code.text}" type="radio" name="code"
  |                       value="${code.text}"
  |                       title="${code.description}"/>
  |   	  </c:forEach>
  |         </frameset>
  |      </firm>
  |   </fmt:bundle>
  | </jsp:root>
  | 

Now the frameset's label is correctly rendered using the appropriate language, and the radio buttons class is set correctly to pick up the correct CSS style sheet.

My problem is how do I code the radio button's "value" and "title" attributes so they get correctly internationalised too?  I really don't want to pass in the servlet request to the editor bean.  Yes it would allow the bean to extract the locale and do the internationisation within itself and thus return the correct string.  However, I think it would be much better to handle all the internationalisation in the JSP file and just have the bean return the keys (or part thereof).  That seams a neater, and therefore better, design to me.

Many thanks for your suggestions
Steve


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4111765#4111765

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4111765



More information about the jboss-user mailing list