html:messages help
Hi, I am having trouble getting messages to display using the html:messages tag. I have tried to help myself and followed the struts docs but I can't seem to get this to work. The html:errors tag works fine. Here's what I am trying to do: I have an action that is trying to add a global message if a certain action is successful. code-snippet ActionMessages messages = new ActionMessages(); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(mesg.pwResetSuccess)); if (!messages.isEmpty()) saveMessages(request, messages); forward = mapping.findForward(GLOBAL_FORWARDS.LOGIN); /code-snippet As you can see I create a messages object, stick my message in it as global and save it. This is pretty much verbatim from the struts user guide. I ran this through a debugger and all code is being executed. This forwards to a jsp page that has the following inside it: code-snippet ul html:messages id=message lic:out value=${message} //li /html:messages /ul /code-snippet When the browser renders the page I get no messages. Any ideas? Thanks, Ross - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:messages help
if (!messages.isEmpty()) saveMessages(request, messages); use addMessages(). saveMessages has been deprecated. ul html:messages id=message lic:out value=${message} //li /html:messages /ul You left out the message attribute. Set it to true. ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:messages help
Hi, Thanks for the response, but no dice, still doesn't work. I changed the jsp to the following: code-snippet ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul /code-snippet I am using Struts 1.1 so I don't have access to addMessages(). Any other suggestions? Thanks, Ross Yan Hu wrote: if (!messages.isEmpty()) saveMessages(request, messages); use addMessages(). saveMessages has been deprecated. ul html:messages id=message lic:out value=${message} //li /html:messages /ul You left out the message attribute. Set it to true. ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:messages help
Try the following... Don't forget to import struts-bean.tld %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean % I think it is better to use struts-tags when possible since they were designed for Struts. ul html:messages id=message message=true li bean:write name=message//li /html:messages /ul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:messages help
Hi, Thanks again but still not working. I tried as you suggested. I don't think it is a problem with the c:out tag anyway because when I look at what the browser gets I see ul /ul And not ul li /li /ul Anyway, I will get the struts source and step through the html:messages code, perhaps there is something fishy going on in there. Ross Yan Hu wrote: Try the following... Don't forget to import struts-bean.tld %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean % I think it is better to use struts-tags when possible since they were designed for Struts. ul html:messages id=message message=true li bean:write name=message//li /html:messages /ul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:messages help
Any chance that you are missing the include for struts-html? %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % Granted I'm using 1.2, but I'm still using the saveMessages(request, messages) and using this to display messages and errors: logic:messagesPresent html:errors/ /logic:messagesPresent logic:messagesPresent message=true html:messages id=msg message=true header=message.header footer=message.footer lifont color=bluebean:write name=msg //font/li /html:messages /logic:messagesPresent Ross Gibb wrote: Hi, Thanks for the response, but no dice, still doesn't work. I changed the jsp to the following: code-snippet ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul /code-snippet I am using Struts 1.1 so I don't have access to addMessages(). Any other suggestions? Thanks, Ross Yan Hu wrote: if (!messages.isEmpty()) saveMessages(request, messages); use addMessages(). saveMessages has been deprecated. ul html:messages id=message lic:out value=${message} //li /html:messages /ul You left out the message attribute. Set it to true. ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:messages help
This could be something. I do have the taglib definition but I am using the el version, so mine looks like this: %@ taglib uri=http://jakarta.apache.org/struts/tags-html-el; prefix=html% Would that make a difference? I will try it the other way. Brad Balmer wrote: Any chance that you are missing the include for struts-html? %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % Granted I'm using 1.2, but I'm still using the saveMessages(request, messages) and using this to display messages and errors: logic:messagesPresent html:errors/ /logic:messagesPresent logic:messagesPresent message=true html:messages id=msg message=true header=message.header footer=message.footer lifont color=bluebean:write name=msg //font/li /html:messages /logic:messagesPresent Ross Gibb wrote: Hi, Thanks for the response, but no dice, still doesn't work. I changed the jsp to the following: code-snippet ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul /code-snippet I am using Struts 1.1 so I don't have access to addMessages(). Any other suggestions? Thanks, Ross Yan Hu wrote: if (!messages.isEmpty()) saveMessages(request, messages); use addMessages(). saveMessages has been deprecated. ul html:messages id=message lic:out value=${message} //li /html:messages /ul You left out the message attribute. Set it to true. ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:messages help
Hi Ross, I know this maybe can't make any sense but i got this problem once due to some mistakes handling scopes. Let me explain: I had an Action instance that did some stuff and in case of errors, put them all in the request and forward to the next view. But my next view was a forward action (a global forward) to a jsp error page. So, when the forward action was executed, the messages saved in the request were lost, resulting in no error messages rendered in my jsp page. May this be your situation? Hope that helped. Cheers, Daniel Silva. On 7/12/05, Ross Gibb [EMAIL PROTECTED] wrote: This could be something. I do have the taglib definition but I am using the el version, so mine looks like this: %@ taglib uri=http://jakarta.apache.org/struts/tags-html-el; prefix=html% Would that make a difference? I will try it the other way. Brad Balmer wrote: Any chance that you are missing the include for struts-html? %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % Granted I'm using 1.2, but I'm still using the saveMessages(request, messages) and using this to display messages and errors: logic:messagesPresent html:errors/ /logic:messagesPresent logic:messagesPresent message=true html:messages id=msg message=true header=message.header footer=message.footer lifont color=bluebean:write name=msg //font/li /html:messages /logic:messagesPresent Ross Gibb wrote: Hi, Thanks for the response, but no dice, still doesn't work. I changed the jsp to the following: code-snippet ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul /code-snippet I am using Struts 1.1 so I don't have access to addMessages(). Any other suggestions? Thanks, Ross Yan Hu wrote: if (!messages.isEmpty()) saveMessages(request, messages); use addMessages(). saveMessages has been deprecated. ul html:messages id=message lic:out value=${message} //li /html:messages /ul You left out the message attribute. Set it to true. ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:messages help
Hi Daniel, Ah yes, that was exactly it, thanks. It may have taken me a long time to figure that out. To save me even more time what was your solution? The global forward I am forwarding to looks like the following in struts-config.xml: global-forwards forward name=login path=/login.do redirect=true/ /global-forwards I want to display a message at the top using html:messages. I seem to recall needing the redirect set to true but I can't remember why. Is that affecting it? Thanks, Ross Daniel Henrique Ferreira e Silva wrote: Hi Ross, I know this maybe can't make any sense but i got this problem once due to some mistakes handling scopes. Let me explain: I had an Action instance that did some stuff and in case of errors, put them all in the request and forward to the next view. But my next view was a forward action (a global forward) to a jsp error page. So, when the forward action was executed, the messages saved in the request were lost, resulting in no error messages rendered in my jsp page. May this be your situation? Hope that helped. Cheers, Daniel Silva. On 7/12/05, Ross Gibb [EMAIL PROTECTED] wrote: This could be something. I do have the taglib definition but I am using the el version, so mine looks like this: %@ taglib uri=http://jakarta.apache.org/struts/tags-html-el; prefix=html% Would that make a difference? I will try it the other way. Brad Balmer wrote: Any chance that you are missing the include for struts-html? %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % Granted I'm using 1.2, but I'm still using the saveMessages(request, messages) and using this to display messages and errors: logic:messagesPresent html:errors/ /logic:messagesPresent logic:messagesPresent message=true html:messages id=msg message=true header=message.header footer=message.footer lifont color=bluebean:write name=msg //font/li /html:messages /logic:messagesPresent Ross Gibb wrote: Hi, Thanks for the response, but no dice, still doesn't work. I changed the jsp to the following: code-snippet ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul /code-snippet I am using Struts 1.1 so I don't have access to addMessages(). Any other suggestions? Thanks, Ross Yan Hu wrote: if (!messages.isEmpty()) saveMessages(request, messages); use addMessages(). saveMessages has been deprecated. ul html:messages id=message lic:out value=${message} //li /html:messages /ul You left out the message attribute. Set it to true. ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: html:messages help
To answer my own question, in this case I was able to remove the redirect attribute and everything works. If I couldn't do that I would have had to stick the messages in the session. Thanks, Ross Ross Gibb wrote: Hi Daniel, Ah yes, that was exactly it, thanks. It may have taken me a long time to figure that out. To save me even more time what was your solution? The global forward I am forwarding to looks like the following in struts-config.xml: global-forwards forward name=login path=/login.do redirect=true/ /global-forwards I want to display a message at the top using html:messages. I seem to recall needing the redirect set to true but I can't remember why. Is that affecting it? Thanks, Ross Daniel Henrique Ferreira e Silva wrote: Hi Ross, I know this maybe can't make any sense but i got this problem once due to some mistakes handling scopes. Let me explain: I had an Action instance that did some stuff and in case of errors, put them all in the request and forward to the next view. But my next view was a forward action (a global forward) to a jsp error page. So, when the forward action was executed, the messages saved in the request were lost, resulting in no error messages rendered in my jsp page. May this be your situation? Hope that helped. Cheers, Daniel Silva. On 7/12/05, Ross Gibb [EMAIL PROTECTED] wrote: This could be something. I do have the taglib definition but I am using the el version, so mine looks like this: %@ taglib uri=http://jakarta.apache.org/struts/tags-html-el; prefix=html% Would that make a difference? I will try it the other way. Brad Balmer wrote: Any chance that you are missing the include for struts-html? %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % Granted I'm using 1.2, but I'm still using the saveMessages(request, messages) and using this to display messages and errors: logic:messagesPresent html:errors/ /logic:messagesPresent logic:messagesPresent message=true html:messages id=msg message=true header=message.header footer=message.footer lifont color=bluebean:write name=msg //font/li /html:messages /logic:messagesPresent Ross Gibb wrote: Hi, Thanks for the response, but no dice, still doesn't work. I changed the jsp to the following: code-snippet ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul /code-snippet I am using Struts 1.1 so I don't have access to addMessages(). Any other suggestions? Thanks, Ross Yan Hu wrote: if (!messages.isEmpty()) saveMessages(request, messages); use addMessages(). saveMessages has been deprecated. ul html:messages id=message lic:out value=${message} //li /html:messages /ul You left out the message attribute. Set it to true. ul html:messages id=message message=true lic:out value=${message} //li /html:messages /ul - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]