You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Caroline Jen <ji...@yahoo.com> on 2003/12/24 00:40:54 UTC
Form and Pass the Form to the Business Tier
My JSP provides several text fields for visitors to
fill out. And my form bean stores those information;
for example:
public String getThreadTopic() {
return threadTopic;
}
public void setThreadTopic(String threadTopic) {
this.threadTopic = threadTopic;
}
public String getThreadBody() {
return threadBody;
}
public void setThreadBody(String threadBody) {
this.threadBody = threadBody;
}
However, I have to supply a number of additional
properties for the business tier to process. For
example, the property threadType is to be assigned to
zero manually and the property parentPostID is to be
found from another class, how do I code them in the
form bean? Do I use get methods shown below (without
set methods)?
public int getThreadType() {
return 0;
}
public int getParentPostID() {
return ParamUtil.getParameterInt( request, "parent"
);
}
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Form and Pass the Form to the Business Tier
Posted by David Erickson <de...@cmcflex.com>.
> Thank you for your response.
>
> According to my understanding of your advice, if I
> want to pass a hidden field from JSP to a form bean, I
> must have name="myFormName" in the JSP's <html:hidden
> .... > tag? Please confirm.
>From the docs:
The attribute name of the bean whose properties are consulted when rendering
the current value of this input field. If not specified, the bean associated
with the form tag we are nested within is utilized. (RT EXPR).
I always put it as good practice.
> Another additional property that is to be assigned a
> value in my form bean is "now" with Timestamp type.
> Do I code this way in my form bean class? Please
> confirm:
>
> pubic Timestamp getNow() {
> return DateUtil.getCurrentGMTTimestamp():
> }
Ya that looks fine.
-David
> -Caroline
> --- David Erickson <de...@cmcflex.com> wrote:
> > >
> > > However, I have to supply a number of additional
> > > properties for the business tier to process. For
> > > example, the property threadType is to be assigned
> > to
> > > zero manually and the property parentPostID is to
> > be
> > > found from another class, how do I code them in
> > the
> > > form bean? Do I use get methods shown below
> > (without
> > > set methods)?
> > >
> > > public int getThreadType() {
> > > return 0;
> > > }
> >
> > This is fine I assume.
> >
> > > public int getParentPostID() {
> > > return ParamUtil.getParameterInt( request,
> > "parent"
> > > );
> > > }
> >
> > This wouldn't work properly. I would make a setter
> > for parentPostID and in
> > the jsp write something like:
> > <html:hidden name="yourformname"
> > property="parentPostID" value="<%=
> > request.getParameter("parent")%>"/>
> >
> > HTH,
> > David
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing.
> http://photos.yahoo.com/
>
> ---------------------------------------------------------------------
> 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: Form and Pass the Form to the Business Tier
Posted by Caroline Jen <ji...@yahoo.com>.
Thank you for your response.
According to my understanding of your advice, if I
want to pass a hidden field from JSP to a form bean, I
must have name="myFormName" in the JSP's <html:hidden
.... > tag? Please confirm.
Another additional property that is to be assigned a
value in my form bean is "now" with Timestamp type.
Do I code this way in my form bean class? Please
confirm:
pubic Timestamp getNow() {
return DateUtil.getCurrentGMTTimestamp():
}
-Caroline
--- David Erickson <de...@cmcflex.com> wrote:
> >
> > However, I have to supply a number of additional
> > properties for the business tier to process. For
> > example, the property threadType is to be assigned
> to
> > zero manually and the property parentPostID is to
> be
> > found from another class, how do I code them in
> the
> > form bean? Do I use get methods shown below
> (without
> > set methods)?
> >
> > public int getThreadType() {
> > return 0;
> > }
>
> This is fine I assume.
>
> > public int getParentPostID() {
> > return ParamUtil.getParameterInt( request,
> "parent"
> > );
> > }
>
> This wouldn't work properly. I would make a setter
> for parentPostID and in
> the jsp write something like:
> <html:hidden name="yourformname"
> property="parentPostID" value="<%=
> request.getParameter("parent")%>"/>
>
> HTH,
> David
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
>
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Form and Pass the Form to the Business Tier
Posted by David Erickson <de...@cmcflex.com>.
>
> However, I have to supply a number of additional
> properties for the business tier to process. For
> example, the property threadType is to be assigned to
> zero manually and the property parentPostID is to be
> found from another class, how do I code them in the
> form bean? Do I use get methods shown below (without
> set methods)?
>
> public int getThreadType() {
> return 0;
> }
This is fine I assume.
> public int getParentPostID() {
> return ParamUtil.getParameterInt( request, "parent"
> );
> }
This wouldn't work properly. I would make a setter for parentPostID and in
the jsp write something like:
<html:hidden name="yourformname" property="parentPostID" value="<%=
request.getParameter("parent")%>"/>
HTH,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org