Jason Long wrote:

I am looking for a way to simplify my ApplicationResources.properties
file.  For example:

errors.header=<div ALIGN="center"><center><TABLE class="error_table"><TR
class="error_tr"><TD class="error_tr">Validation Error<hr/></TD></TR>
errors.footer=</TABLE></center></div>
error.footageRequired.integer=<TR class="error_tr"><TD
class="error_td"><img src="images/star.gif" border="0" />Footage
required must be a positive integer</TD></TR>
error.chkItems.required=<TR class="error_tr"><TD class="error_td"><img
src="images/star.gif" border="0" />At least 1 item must be
selected</TD></TR>


I basically do not want to put <TR class="error_tr"><TD class="error_td"><img src="images/star.gif" border="0" /> in front of each entry or </TD></TR> following them.

Is this already possible?

If you look at this: http://jakarta.apache.org/struts/userGuide/struts-html.html#messages

You can use it like so:

<logic:messagesPresent>
    <div ALIGN="center">
      <center>
        <TABLE class="error_table">
          <TR class="error_tr">
            <TD class="error_tr">Validation Error<hr/></TD>
          </TR>
          <html:messages id="error">
            <TR class="error_tr">
              <TD class="error_td"><img src="images/star.gif"
> border="0" /><c:out value="${error}" /></TD>
            </TR>
          </html:messages>
        </TABLE>
     </center>
  </div>
</logic:messagesPresent>

In your ApplicationResources.properties file you just need:

error.footageRequired.integer=Footage required must be a positive integer
error.chkItems.required=At least 1 item must be selected

Much more tidy :) and we don't need errors.header or errors.footer

The <html:messages> tag will iterate over the ActionErrors, so you don't need to put markup in your .properties file. The <logic:messagesPresent> will mean the table will only be displayed if there are errors.

I use the JSTL way <c:out value="${error}" /> of outputting the error message, but you could use <bean:write name="error"/> I think.


Jason Long - CEO and Chief Software Engineer
Supernova Software - supernovasoftware.com
BS Physics, MS Chemical Engineering



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




--
Jason Lea


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to