You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ciaran Hanley <ci...@sentenial.ie> on 2004/01/09 17:44:17 UTC
Problem displaying ActionMessages in JSP
Hello
Can anybody help me? I am trying to display messages on my JSP based on
whether an insertion to the DB was successful or not.
Properties file:
dbsuccess.add = Database Success: Details Added
dberror.add = Database Error: Unable To Add Details At This Time
Action Class:
/* create ActionErrors instance to hold success/failure messages */
ActionMessages messages = new ActionMessages();
try
{
......business logic
messages.add(ActionMessages.GLOBAL_MESSAGE, new
ActionMessage("dbsuccess.add"));
setSession(messages, request);
}
catch (Exception e)
{
messages.add(ActionMessages.GLOBAL_MESSAGE, new
ActionMessage("dberror.add""));
setSession(messages, request);
}
private void setSession(ActionMessages messages, HttpServletRequest
request)
{
/* put the messages in the session */
request.getSession().getServletContext().setAttribute("messages",
messages);
}
JSP file:
<logic:messagesPresent message="true">
<font color="red"><UL>
<html:messages id="messages">
<LI>
<bean:write name="messages" />
</LI>
</html:messages>
</UL></font><hr>
</logic:messagesPresent>
Nothing is being printed at the top of the page, the insertion into the
database works fine but I cant get the success message up. Does anybody
know why this is happening?
Thanks,
Ciaran
RE: Problem displaying ActionMessages in JSP
Posted by Ciaran Hanley <ci...@sentenial.ie>.
I already had the message="true" part in the JSP code.
I changed the id and name value to "message" as you said but I get the
same result, just the <hr> is produced
Ciaran
-----Original Message-----
From: Hubert Rabago [mailto:jakartauser@yahoo.com]
Sent: 09 January 2004 17:16
To: Struts Users Mailing List
Subject: RE: Problem displaying ActionMessages in JSP
also, add message="true" to your <html:messages>:
<html:messages id="messages" message="true">
<bean:write name="messages"/><br>
</html:messages>
While your at it, you can use id="message" and name="message" because
AFAIK, that
identifier will be used to refer to a single message.
--- Ciaran Hanley <ci...@sentenial.ie> wrote:
> Thanks Hubert,
>
> That has me going in the right direction, however only the <hr>
element
> is printing at the top of the page now. The message elements aren't
> getting printed as they should. Can anybody spot the problem, I cant
>
> Thanks,
> Ciaran
>
>
> -----Original Message-----
> From: Hubert Rabago [mailto:jakartauser@yahoo.com]
> Sent: 09 January 2004 16:56
> To: Struts Users Mailing List
> Subject: Re: Problem displaying ActionMessages in JSP
>
> try calling saveMessages(request,messages) in your action class.
>
> --- Ciaran Hanley <ci...@sentenial.ie> wrote:
> > Hello
> > Can anybody help me? I am trying to display messages on my JSP based
> on
> > whether an insertion to the DB was successful or not.
> >
> > Properties file:
> >
> > dbsuccess.add = Database Success: Details Added
> > dberror.add = Database Error: Unable To Add Details At This Time
> >
> >
> >
> > Action Class:
> >
> > /* create ActionErrors instance to hold success/failure messages */
> > ActionMessages messages = new ActionMessages();
> >
> > try
> > {
> > ......business logic
> >
> > messages.add(ActionMessages.GLOBAL_MESSAGE, new
> > ActionMessage("dbsuccess.add"));
> > setSession(messages, request);
> > }
> > catch (Exception e)
> > {
> > messages.add(ActionMessages.GLOBAL_MESSAGE, new
> > ActionMessage("dberror.add""));
> > setSession(messages, request);
> > }
> >
> >
> > private void setSession(ActionMessages messages, HttpServletRequest
> > request)
> > {
> > /* put the messages in the session */
> >
> request.getSession().getServletContext().setAttribute("messages",
> > messages);
> > }
> >
> >
> > JSP file:
> >
> > <logic:messagesPresent message="true">
> > <font color="red"><UL>
> > <html:messages id="messages">
> > <LI>
> > <bean:write name="messages" />
> > </LI>
> > </html:messages>
> > </UL></font><hr>
> > </logic:messagesPresent>
> >
> > Nothing is being printed at the top of the page, the insertion into
> the
> > database works fine but I cant get the success message up. Does
> anybody
> > know why this is happening?
> >
> > Thanks,
> > Ciaran
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Problem displaying ActionMessages in JSP
Posted by Hubert Rabago <ja...@yahoo.com>.
also, add message="true" to your <html:messages>:
<html:messages id="messages" message="true">
<bean:write name="messages"/><br>
</html:messages>
While your at it, you can use id="message" and name="message" because AFAIK, that
identifier will be used to refer to a single message.
--- Ciaran Hanley <ci...@sentenial.ie> wrote:
> Thanks Hubert,
>
> That has me going in the right direction, however only the <hr> element
> is printing at the top of the page now. The message elements aren't
> getting printed as they should. Can anybody spot the problem, I cant
>
> Thanks,
> Ciaran
>
>
> -----Original Message-----
> From: Hubert Rabago [mailto:jakartauser@yahoo.com]
> Sent: 09 January 2004 16:56
> To: Struts Users Mailing List
> Subject: Re: Problem displaying ActionMessages in JSP
>
> try calling saveMessages(request,messages) in your action class.
>
> --- Ciaran Hanley <ci...@sentenial.ie> wrote:
> > Hello
> > Can anybody help me? I am trying to display messages on my JSP based
> on
> > whether an insertion to the DB was successful or not.
> >
> > Properties file:
> >
> > dbsuccess.add = Database Success: Details Added
> > dberror.add = Database Error: Unable To Add Details At This Time
> >
> >
> >
> > Action Class:
> >
> > /* create ActionErrors instance to hold success/failure messages */
> > ActionMessages messages = new ActionMessages();
> >
> > try
> > {
> > ......business logic
> >
> > messages.add(ActionMessages.GLOBAL_MESSAGE, new
> > ActionMessage("dbsuccess.add"));
> > setSession(messages, request);
> > }
> > catch (Exception e)
> > {
> > messages.add(ActionMessages.GLOBAL_MESSAGE, new
> > ActionMessage("dberror.add""));
> > setSession(messages, request);
> > }
> >
> >
> > private void setSession(ActionMessages messages, HttpServletRequest
> > request)
> > {
> > /* put the messages in the session */
> >
> request.getSession().getServletContext().setAttribute("messages",
> > messages);
> > }
> >
> >
> > JSP file:
> >
> > <logic:messagesPresent message="true">
> > <font color="red"><UL>
> > <html:messages id="messages">
> > <LI>
> > <bean:write name="messages" />
> > </LI>
> > </html:messages>
> > </UL></font><hr>
> > </logic:messagesPresent>
> >
> > Nothing is being printed at the top of the page, the insertion into
> the
> > database works fine but I cant get the success message up. Does
> anybody
> > know why this is happening?
> >
> > Thanks,
> > Ciaran
> >
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: Problem displaying ActionMessages in JSP
Posted by Ciaran Hanley <ci...@sentenial.ie>.
Thanks Hubert,
That has me going in the right direction, however only the <hr> element
is printing at the top of the page now. The message elements aren't
getting printed as they should. Can anybody spot the problem, I cant
Thanks,
Ciaran
-----Original Message-----
From: Hubert Rabago [mailto:jakartauser@yahoo.com]
Sent: 09 January 2004 16:56
To: Struts Users Mailing List
Subject: Re: Problem displaying ActionMessages in JSP
try calling saveMessages(request,messages) in your action class.
--- Ciaran Hanley <ci...@sentenial.ie> wrote:
> Hello
> Can anybody help me? I am trying to display messages on my JSP based
on
> whether an insertion to the DB was successful or not.
>
> Properties file:
>
> dbsuccess.add = Database Success: Details Added
> dberror.add = Database Error: Unable To Add Details At This Time
>
>
>
> Action Class:
>
> /* create ActionErrors instance to hold success/failure messages */
> ActionMessages messages = new ActionMessages();
>
> try
> {
> ......business logic
>
> messages.add(ActionMessages.GLOBAL_MESSAGE, new
> ActionMessage("dbsuccess.add"));
> setSession(messages, request);
> }
> catch (Exception e)
> {
> messages.add(ActionMessages.GLOBAL_MESSAGE, new
> ActionMessage("dberror.add""));
> setSession(messages, request);
> }
>
>
> private void setSession(ActionMessages messages, HttpServletRequest
> request)
> {
> /* put the messages in the session */
>
request.getSession().getServletContext().setAttribute("messages",
> messages);
> }
>
>
> JSP file:
>
> <logic:messagesPresent message="true">
> <font color="red"><UL>
> <html:messages id="messages">
> <LI>
> <bean:write name="messages" />
> </LI>
> </html:messages>
> </UL></font><hr>
> </logic:messagesPresent>
>
> Nothing is being printed at the top of the page, the insertion into
the
> database works fine but I cant get the success message up. Does
anybody
> know why this is happening?
>
> Thanks,
> Ciaran
>
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Problem displaying ActionMessages in JSP
Posted by Hubert Rabago <ja...@yahoo.com>.
try calling saveMessages(request,messages) in your action class.
--- Ciaran Hanley <ci...@sentenial.ie> wrote:
> Hello
> Can anybody help me? I am trying to display messages on my JSP based on
> whether an insertion to the DB was successful or not.
>
> Properties file:
>
> dbsuccess.add = Database Success: Details Added
> dberror.add = Database Error: Unable To Add Details At This Time
>
>
>
> Action Class:
>
> /* create ActionErrors instance to hold success/failure messages */
> ActionMessages messages = new ActionMessages();
>
> try
> {
> ......business logic
>
> messages.add(ActionMessages.GLOBAL_MESSAGE, new
> ActionMessage("dbsuccess.add"));
> setSession(messages, request);
> }
> catch (Exception e)
> {
> messages.add(ActionMessages.GLOBAL_MESSAGE, new
> ActionMessage("dberror.add""));
> setSession(messages, request);
> }
>
>
> private void setSession(ActionMessages messages, HttpServletRequest
> request)
> {
> /* put the messages in the session */
> request.getSession().getServletContext().setAttribute("messages",
> messages);
> }
>
>
> JSP file:
>
> <logic:messagesPresent message="true">
> <font color="red"><UL>
> <html:messages id="messages">
> <LI>
> <bean:write name="messages" />
> </LI>
> </html:messages>
> </UL></font><hr>
> </logic:messagesPresent>
>
> Nothing is being printed at the top of the page, the insertion into the
> database works fine but I cant get the success message up. Does anybody
> know why this is happening?
>
> Thanks,
> Ciaran
>
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org