If the userId is a hidden property of the form, then it would be
submitted along with all the visible properties, and be populated to the
ActionForm with all the others. Try changing the method to get
(temporarily) to see what is actually being submitted.

"Jakkampudi, ChandraseKhar" wrote:
> 
> The userID property is already in the action form. Only, it is a hidden
> property which is neither displayed on the form or updated. It is only there
> to update the proper record when the object is modified. It is not retained
> when validation fails. Thus I get a database error when I update because the
> primary key (userid) is null.  All other properties (that are not hidden)
> are retained. I cannot understand why this happens. I am surprised that
> nobody else has this problem which leads me to think that I am doing
> something wrong. Any help is really appreciated.
> 
> -JC
> 
> -----Original Message-----
> From: Ted Husted [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 14, 2002 5:46 PM
> To: Struts Users Mailing List
> Subject: Re: Request: Property vs Attribute
> 
> You might try adding the userId property to the ActionForm, and seeing
> if that approach works better for you.
> 
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Java Web Development with Struts.
> -- Tel +1 585 737-3463.
> -- Web http://www.husted.com/struts/
> 
> "Jakkampudi, ChandraseKhar" wrote:
> >
> > The form is initially populated from a value object like
> >
> > <html:text property="userName" value="<%=userInfo.getUserName()%>"/>
> > and
> > <html:hidden property="userID" value="<%=userInfo.getUserID()%>"/>
> >
> > userInfo is not my ActionForm bean, rather it is a value object that is
> > created as part of the previous request (via a database call) that
> specifies
> > which userId is to be modified. This is also in request scope.
> >
> > On coming back to the input page when validation fails etc. the user name
> is
> > retained (magic of struts action form bean) but not the user Id which is
> why
> > I used the request.setAttribute in the first place.
> >
> > Is this not the right way to do things? Any help is appreciated.
> >
> > -JC
> >
> > -----Original Message-----
> > From: Ted Husted [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, February 14, 2002 4:03 PM
> > To: Struts Users Mailing List
> > Subject: Re: Request: Property vs Attribute
> >
> > As long as it is on the ActionForm bean, you can have the action put the
> > UserID there.
> >
> > While the request attributes are there, and there's nothing to prevent
> > you from using them, everything really does work a lot better if you
> > forget about the parameters, and use the ActionForm bean instead.
> >
> > -- Ted Husted, Husted dot Com, Fairport NY USA.
> > -- Java Web Development with Struts.
> > -- Tel +1 585 737-3463.
> > -- Web http://www.husted.com/struts/
> >
> > "Jakkampudi, ChandraseKhar" wrote:
> > >
> > > UserID is a member of my action form sub class. I do not have a reset
> > method
> > > defined and I do not use the html:reset.
> > > I do use html:hidden tag as you suggested but for scalability and other
> > > reasons I do not use a session scoped form but use request scope.
> > >
> > > -JC
> > >
> > > -----Original Message-----
> > > From: Pedone, Tim [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, February 14, 2002 3:44 PM
> > > To: 'Struts Users Mailing List'
> > > Subject: RE: Request: Property vs Attribute
> > >
> > > Is userID a member of your ActionForm subclass? If you make it a member
> of
> > > your ActionForm, it will get maintained (provided you don't wipe it out
> in
> > > your reset() method) for you if you have a <html:hidden
> > property="userID"/>
> > > tag in your jsp. I tried this using a session scoped form and it worked.
> > >
> > > Tim
> > >
> > > -----Original Message-----
> > > From: Jakkampudi, ChandraseKhar [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, February 14, 2002 12:29 PM
> > > To: 'Struts Users Mailing List'
> > > Subject: Request: Property vs Attribute
> > >
> > > I have a jsp that displays details of a user. The display is in a form
> > that
> > > can also be used to modify user details. Access to this page is via a
> url
> > > like http://xyz.com/userDetails.do?userID=123. However the userid is not
> a
> > > editable field and I use a hidden variable to pass this information back
> > to
> > > the server fo updates. On validation, if I return to the input page, the
> > > hidden variable is lost. So I use request.setAttribute("userID", "123")
> in
> > > the perform method of the action before redirecting to set the
> information
> > > back.
> > >
> > > However because of this I have to have this conditional at the top of my
> > jsp
> > >
> > > String userID = request.getParameter("userID");
> > > if (userID == null){
> > >         userID = (String) request.getAttribute("userID");
> > > }
> > >
> > > This is because the logic:present tag just uses the getParameter command
> > and
> > > returns false even if the required string is an attribute of the
> request.
> > > I know I can change the source, but it would be difficult to maintain as
> I
> > > have to remember this fact everytime we do an upgrade.
> > >
> > > Any suggestions on how to implement this better without using
> scriptlets.
> > >
> > > -JC
> > >
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Java Web Development with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/

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

Reply via email to