0 Replies Latest reply on Dec 10, 2007 4:36 PM by Steve Dobson

    JSP, I18n and XML

    Steve Dobson Newbie

      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