You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Richard Yumul <rm...@polexis.com> on 2001/03/15 01:50:27 UTC

Is there a particular reason why the <logic:present> tag from the
struts-logic taglib can't check if a value has been set in the request w/
the Servlet.setAttribute() method?

It seems like this would be common design pattern:

	The Action class successfully processes some submitted form data,

	It adds some info to the request object
(HttpServletRequest.setAttribute()),
	(like a status message of the whatever the form was supposed to do)

	Passes control to whatever the mapping.findforward() method returns;

	Then the JSP displays the page with the status message w/ a
request.getAttribute().

Essentially, I'd like to avoid a:

<%
	String mesg = request.getAttribute("status.message");
	if (mesg != null) {
		out.println(mesg);
	}
%>

in my JSP page and leverage as much as I can from the taglibs.  Does struts
provide any other mechanism to accomplish this?


Thanks,
Rich


Richard M. Yumul
Polexis, Inc.
http://www.polexis.com
transforming data into knowledge


Re:

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 14 Mar 2001, Richard Yumul wrote:

> Is there a particular reason why the <logic:present> tag from the
> struts-logic taglib can't check if a value has been set in the request w/
> the Servlet.setAttribute() method?
> 
> It seems like this would be common design pattern:
> 
> 	The Action class successfully processes some submitted form data,
> 
> 	It adds some info to the request object
> (HttpServletRequest.setAttribute()),
> 	(like a status message of the whatever the form was supposed to do)
> 
> 	Passes control to whatever the mapping.findforward() method returns;
> 
> 	Then the JSP displays the page with the status message w/ a
> request.getAttribute().
> 
> Essentially, I'd like to avoid a:
> 
> <%
> 	String mesg = request.getAttribute("status.message");
> 	if (mesg != null) {
> 		out.println(mesg);
> 	}
> %>
> 
> in my JSP page and leverage as much as I can from the taglibs.  Does struts
> provide any other mechanism to accomplish this?
> 

Doesn't this do what you want?

	<logic:present name="status.message" scope="request">
		<bean:write name="status.message"/>
	</logic:present>

Request attributes (in an Action) are the same as request scope beans (in
a JSP page).

> 
> Thanks,
> Rich
> 

Craig McClanahan


Re:

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 14 Mar 2001, Richard Yumul wrote:

> Is there a particular reason why the <logic:present> tag from the
> struts-logic taglib can't check if a value has been set in the request w/
> the Servlet.setAttribute() method?
> 
> It seems like this would be common design pattern:
> 
> 	The Action class successfully processes some submitted form data,
> 
> 	It adds some info to the request object
> (HttpServletRequest.setAttribute()),
> 	(like a status message of the whatever the form was supposed to do)
> 
> 	Passes control to whatever the mapping.findforward() method returns;
> 
> 	Then the JSP displays the page with the status message w/ a
> request.getAttribute().
> 
> Essentially, I'd like to avoid a:
> 
> <%
> 	String mesg = request.getAttribute("status.message");
> 	if (mesg != null) {
> 		out.println(mesg);
> 	}
> %>
> 
> in my JSP page and leverage as much as I can from the taglibs.  Does struts
> provide any other mechanism to accomplish this?
> 

Doesn't this do what you want?

	<logic:present name="status.message" scope="request">
		<bean:write name="status.message"/>
	</logic:present>

Request attributes (in an Action) are the same as request scope beans (in
a JSP page).

> 
> Thanks,
> Rich
> 

Craig McClanahan