You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by draegoon Z <dr...@hotmail.com> on 2005/08/22 20:19:51 UTC

messages help

Sorry, but I've been reading archives all morning.

Using Struts 1.2.7

Setting up a system to catch all errors/messages on a page.

Getting the errors from my ActionForm:

ActionErrors errors = new ActionErrors();
errors.add("system_name",new 
ActionError("errors.required",ar.getMessage("com.draegoonZ.social.label.system_name")));
return(errors);

Getting the ???bad_key??? from my ActionForm:

ActionMessages errors = new ActionMessages();
errors.add("system_name",new 
ActionMessage(ar.getMessage("com.draegoonZ.social.password.lookup.no_user_name")));
saveMessages(request,errors);
return(mapping.getInputForward());

Results in: ???en_US.That username doesn't exist in our system. Please try 
again.???

Now I don't know what key it is telling me is missing,
when it is displaying the value from my messages resource.

I thought the problem was with using the property (system_name)
instead of ActionMessages.GLOBAL_MESSAGE, but that gave the
same results.

Also, I want to use the property name, so I can display next to the <html:> 
input tag.

A related question I have is:

I read somewhere (this morning) that once html:message is read/accessed that 
it is removed/deleted.
Is this true?
How then could one list all the errors/messages at the top of a page,
and then check for them to display next to the <html:> input tag?


My jsp reads:

	<%-- check for errors --%>
	<logic:messagesPresent>
            <html:messages id="message_id" header="errors.header" 
footer="errors.footer">
                <li><c:out value="${message_id}" /></li>
            </html:messages>
        </logic:messagesPresent>

        <%-- If not errors present... --%>
        <logic:messagesNotPresent>

            <%-- check for messages (Globals.MESSAGE_KEY) --%>
            <logic:messagesPresent message="true">
                <html:messages id="message_id" message="true" 
header="errors.header" footer="errors.footer">
                    <li><c:out value="${message_id}" /></li>
                </html:messages>
            </logic:messagesPresent>
        </logic:messagesNotPresent>


Thanx in advance.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: messages help

Posted by gl...@cmhc.ca.
Did you read this ?
http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html

Especially the section 4.2 Using a Custom Key.

HTH,
Glenn




"draegoon Z" <dr...@hotmail.com> 
22/08/2005 02:19 PM
Please respond to
"Struts Users Mailing List" <us...@struts.apache.org>


To
struts-user@jakarta.apache.org
cc

Subject
messages help






Sorry, but I've been reading archives all morning.

Using Struts 1.2.7

Setting up a system to catch all errors/messages on a page.

Getting the errors from my ActionForm:

ActionErrors errors = new ActionErrors();
errors.add("system_name",new 
ActionError("errors.required",ar.getMessage("com.draegoonZ.social.label.system_name")));
return(errors);

Getting the ???bad_key??? from my ActionForm:

ActionMessages errors = new ActionMessages();
errors.add("system_name",new 
ActionMessage(ar.getMessage("com.draegoonZ.social.password.lookup.no_user_name")));
saveMessages(request,errors);
return(mapping.getInputForward());

Results in: ???en_US.That username doesn't exist in our system. Please try 

again.???

Now I don't know what key it is telling me is missing,
when it is displaying the value from my messages resource.

I thought the problem was with using the property (system_name)
instead of ActionMessages.GLOBAL_MESSAGE, but that gave the
same results.

Also, I want to use the property name, so I can display next to the 
<html:> 
input tag.

A related question I have is:

I read somewhere (this morning) that once html:message is read/accessed 
that 
it is removed/deleted.
Is this true?
How then could one list all the errors/messages at the top of a page,
and then check for them to display next to the <html:> input tag?


My jsp reads:

                 <%-- check for errors --%>
                 <logic:messagesPresent>
            <html:messages id="message_id" header="errors.header" 
footer="errors.footer">
                <li><c:out value="${message_id}" /></li>
            </html:messages>
        </logic:messagesPresent>

        <%-- If not errors present... --%>
        <logic:messagesNotPresent>

            <%-- check for messages (Globals.MESSAGE_KEY) --%>
            <logic:messagesPresent message="true">
                <html:messages id="message_id" message="true" 
header="errors.header" footer="errors.footer">
                    <li><c:out value="${message_id}" /></li>
                </html:messages>
            </logic:messagesPresent>
        </logic:messagesNotPresent>


Thanx in advance.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org