struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kris Schneider <k...@dotech.com>
Subject RE: Keeping request parameters available during Validation
Date Thu, 01 May 2003 13:57:53 GMT
Coming in late to the thread, apologies if this misses the mark. I'm assuming
you've got a form that submits to some action (/someAction) and a link that
submits to another action (/recurserAction) on the same page. Is that right? If
you can use JSTL, here's something that might help:

<%-- The following block avoids hardcoding the form name --%>
<bean:struts id="mapping" mapping="/someAction"/>
<bean:define id="attribute" name="mapping" property="attribute"/>
<bean:define id="scope" name="mapping" property="scope"/>
<bean:define id="form"
             name="<%= String.valueOf(attribute) %>"
             scope="<%= String.valueOf(scope) %>"/>

<jsp:useBean id="paramMap" class="java.util.HashMap"/>
<c:set target="${paramMap}" property="pid" value="new"/>
<%-- use form.map.root for a DynaActionForm --%>
<c:set target="${paramMap}" property="id" value="${form.root}"/>

<html:link action="/recurserAction" name="paramMap">
  Back to project
</html:link>

<html:form action="/someAction">
  <html:hidden property="root"/>
  ...
</html:form>

Or create paramMap in an action and set it as the value of a request attribute.

Quoting Becky Norum <bnorum@coe.neu.edu>:

> Susan,
> 
> Thanks for the input - I already do have it as a hidden property and
> that works, yet trying to reference it within a URL doesn't!
> 
> JSP:
> ----
>  <a
> href="/recurserAction.action?pid=new&id='<%=request.getParameter("root")%>'">Back
> to project</a href>
> 
> <html:hidden property="root" value='<%=request.getParameter("root")%>'/>
> ---
> 
> generates an HTML page:
> 
> Back to Project (linking to
> http://localhost:8080/censsisdb/recurserAction.action?pid=new&id=null)
>                                                                  *****
> 
> and a hidden form field correctly populated as:
> 
> <input type="hidden" name="root" value="201">
> 
> -----
> 
> So, I'm VERY VERY confused - maybe there is something intrinsic about
> the struts form validation and how it generates the web page that I
> don't understand..
> 
> Any form gurus out there?
> 
> Thanks!
> Becky
> 
> 
> 
> On Thu, 2003-05-01 at 08:36, Susan Bradeen wrote:
> > If root is a property on your ActionForm, perhaps you can do something 
> > like
> > 
> > <html:hidden property="root" value='<%=request.getParameter("root")%>'
/>
> 
> > 
> > to actually populate it as an ActionForm param for use after validation? 
> > Kind of a guess.
> > 
> > Susan Bradeen
> > 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


-- 
Kris Schneider <mailto:kris@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Mime
View raw message