> So the question is this - how do I retain values of nested properties that
> aren't required to be (or cannot be) represented in the jsp? 

The only values that you'll get when the form is submitted are the
values that the form has.
If you have values that you want to submit with the form, but don't
want them displayed to the user, look at hidden fields <html:hidden
/>.


> It appears that
> the value of premises is always null and not using what is in the request
> scope when the jsp is submitted. 

Roughly, a "request" begins when the browser asks for information from
the server, and ends when the server has supplied that information. 
After you've created your Premises object and displayed it on your
JSP's form, the request is done.  When the user submits the form, that
counts as another request, a new, empty, fresh one, with nothing yet
in its scope, except for the data that comes with the form being
submitted.

If you want your form to persist between requests, put your form in
session scope.  Take a look at
http://java.sun.com/developer/EJTechTips/2003/tt1209.html#2 for a
better explanation of the differences between scopes.


Here's another link that might help you manage your form data,
particularly collections that you may place in <select> controls:
http://www.reumann.net/struts/articles/request_lists.jsp

hth,
Hubert


On Wed, 19 Jan 2005 13:02:20 +0000, Conrad CRAMPTON PSE 52704
<[EMAIL PROTECTED]> wrote:
>  
> Hi, 
> The list archive search doesn't appear to work to forgive me if this is a
> simple and already answered topic. 
>   
> I have an actionform that has an object as a property - Premises premises,
> and a jsp that uses <html:text name="Premises" property="premises.name" />. 
> When I use createPremises.jsp all is ok and the values for premises get
> through to my action no problem. 
>   
> The problem I have though is when I want to edit premises. The action
> (extending Dispatchaction) viz... 
>   
> public ActionForward edit(ActionMapping mapping, ActionForm form,
> HttpServletRequest request, HttpServletResponse response) throws
> IOException, ServletException {
>   PremisesForm premForm = (PremisesForm) form;
>   String returnMapping = "edit";
>   Long id = null;
>   if (request.getParameter("id") != null)
>    id = new Long(request.getParameter("id"));
>   if (id == null)
>    id = (Long) request.getAttribute("id");
>   try {
>    PremisesDAO pdao = new PremisesDAO();
>    Premises prem = pdao.getPremises(id);
>    premForm.setPremises(prem);
>    premForm.setOwner(prem.getOwner());
>    request.setAttribute("Premises", premForm);
>   } catch (DataAccessException e) {
>    e.printStackTrace();
>    returnMapping = "error";
>    request.setAttribute("error", e.getMessage());
>   }
>   return mapping.findForward(returnMapping);
>  }
>  
> which is fine and sets the PremisesForm premises attribute correctly.
> However when this gets submitted ultimately from the jsp, the properties of
> premises that aren't html:text elements in my jsp aren't being retained.
> e.g. id (primary key of premises from db, and other things like collections
> of other pojo's in premises. 
>   
> So the question is this - how do I retain values of nested properties that
> aren't required to be (or cannot be) represented in the jsp? It appears that
> the value of premises is always null and not using what is in the request
> scope when the jsp is submitted. 
>   
> I am sure this is simple answer but I just can't get it! 
>   
> TIA 
> Conrad 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to