You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marc Dugger <ma...@socotech.com> on 2003/10/18 18:35:57 UTC

populating form fields from request params

I am using the same form to both create and update database entities.  The
following is an example of a form field:

<html-el:select property='documentStatusTypeId'
value='${note.auditIdentity.documentStatusType.id}'
onchange="editNoteForm.action=''; editNoteForm.submit(); return true;">
	<html:options collection='<%=ContextKey.DOCUMENT_STATUS_TYPES%>'
property='id' labelProperty='name' />
</html-el:select>

And from my struts-config.xml:

<form-bean name="editNoteForm"
type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
          <form-property name="noteId" type="java.lang.Integer" />
          <form-property name="documentStatusTypeId"
type="java.lang.Integer" />
... yada, yada, yada ...
</form-bean>

As you can see, if this field changes the page is reloaded.  Problem:  if
${note.auditIdentity} returns null (which would be the case if I was
creating a new entity) the property is not being populated from form bean.
How do I specify that if value is <null>, populate from form bean's
property?
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.525 / Virus Database: 322 - Release Date: 10/9/2003


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


Re: populating form fields from request params

Posted by Martin Gainty <mg...@hotmail.com>.
Offshore development reduces costs? Is there any businessman that believes
in that lie?
Last project I worked on that went offshore the vendor wound up in court
after delivering non-operational code AND putting a few million on their
back pocket.
No Thanks,
Martin
----- Original Message ----- 
From: "Marc Dugger" <ma...@socotech.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Saturday, October 18, 2003 3:21 PM
Subject: RE: populating form fields from request params


> I thought I could resolve this by specifiying:
>
>  value='${true ? param.documentStatusTypeId :
> note.auditIdentity.documentStatusType.id}'
>
> ...but this did not work.  Is the ternary operator not supported yet in
> struts-el?  (I'm using struts-el-1.1.jar)
>
>
>
> > -----Original Message-----
> > From: Martin Gainty [mailto:mgainty@hotmail.com]
> > Sent: Saturday, October 18, 2003 1:25 PM
> > To: Struts Users Mailing List; marc@socotech.com
> > Subject: Re: populating form fields from request params
> >
> >
> > check out
> > http://jakarta.apache.org/struts/userGuide/struts-html.html#options
> >
> > (I wouldnt use collection in this case..I assume we are returning scalar
> > entity)
> > to paraphrase
> > "where  collection of values actually selected depends on the presence
or
> > absence of the name and property attributes"
> > the name or property being null can be tested and value assigned can be
> > ascertained.
> > Keep me informed,
> > -Martin
> > ----- Original Message -----
> > From: "Marc Dugger" <ma...@socotech.com>
> > To: <st...@jakarta.apache.org>
> > Sent: Saturday, October 18, 2003 12:35 PM
> > Subject: populating form fields from request params
> >
> >
> > > I am using the same form to both create and update database
> > entities.  The
> > > following is an example of a form field:
> > >
> > > <html-el:select property='documentStatusTypeId'
> > > value='${note.auditIdentity.documentStatusType.id}'
> > > onchange="editNoteForm.action=''; editNoteForm.submit(); return
true;">
> > > <html:options collection='<%=ContextKey.DOCUMENT_STATUS_TYPES%>'
> > > property='id' labelProperty='name' />
> > > </html-el:select>
> > >
> > > And from my struts-config.xml:
> > >
> > > <form-bean name="editNoteForm"
> > > type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
> > >           <form-property name="noteId" type="java.lang.Integer" />
> > >           <form-property name="documentStatusTypeId"
> > > type="java.lang.Integer" />
> > > ... yada, yada, yada ...
> > > </form-bean>
> > >
> > > As you can see, if this field changes the page is reloaded.
> > Problem:  if
> > > ${note.auditIdentity} returns null (which would be the case if I was
> > > creating a new entity) the property is not being populated from
> > form bean.
> > > How do I specify that if value is <null>, populate from form bean's
> > > property?
> > > ---
> > > Outgoing mail is certified Virus Free.
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.525 / Virus Database: 322 - Release Date: 10/9/2003
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> > ---
> > Incoming mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.525 / Virus Database: 322 - Release Date: 10/9/2003
> >
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.525 / Virus Database: 322 - Release Date: 10/9/2003
>
>
> ---------------------------------------------------------------------
> 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: populating form fields from request params

Posted by Marc Dugger <ma...@socotech.com>.
I thought I could resolve this by specifiying:

 value='${true ? param.documentStatusTypeId :
note.auditIdentity.documentStatusType.id}'

...but this did not work.  Is the ternary operator not supported yet in
struts-el?  (I'm using struts-el-1.1.jar)



> -----Original Message-----
> From: Martin Gainty [mailto:mgainty@hotmail.com]
> Sent: Saturday, October 18, 2003 1:25 PM
> To: Struts Users Mailing List; marc@socotech.com
> Subject: Re: populating form fields from request params
>
>
> check out
> http://jakarta.apache.org/struts/userGuide/struts-html.html#options
>
> (I wouldnt use collection in this case..I assume we are returning scalar
> entity)
> to paraphrase
> "where  collection of values actually selected depends on the presence or
> absence of the name and property attributes"
> the name or property being null can be tested and value assigned can be
> ascertained.
> Keep me informed,
> -Martin
> ----- Original Message -----
> From: "Marc Dugger" <ma...@socotech.com>
> To: <st...@jakarta.apache.org>
> Sent: Saturday, October 18, 2003 12:35 PM
> Subject: populating form fields from request params
>
>
> > I am using the same form to both create and update database
> entities.  The
> > following is an example of a form field:
> >
> > <html-el:select property='documentStatusTypeId'
> > value='${note.auditIdentity.documentStatusType.id}'
> > onchange="editNoteForm.action=''; editNoteForm.submit(); return true;">
> > <html:options collection='<%=ContextKey.DOCUMENT_STATUS_TYPES%>'
> > property='id' labelProperty='name' />
> > </html-el:select>
> >
> > And from my struts-config.xml:
> >
> > <form-bean name="editNoteForm"
> > type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
> >           <form-property name="noteId" type="java.lang.Integer" />
> >           <form-property name="documentStatusTypeId"
> > type="java.lang.Integer" />
> > ... yada, yada, yada ...
> > </form-bean>
> >
> > As you can see, if this field changes the page is reloaded.
> Problem:  if
> > ${note.auditIdentity} returns null (which would be the case if I was
> > creating a new entity) the property is not being populated from
> form bean.
> > How do I specify that if value is <null>, populate from form bean's
> > property?
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.525 / Virus Database: 322 - Release Date: 10/9/2003
> >
> >
> > ---------------------------------------------------------------------
> > 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
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.525 / Virus Database: 322 - Release Date: 10/9/2003
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.525 / Virus Database: 322 - Release Date: 10/9/2003


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


Re: populating form fields from request params

Posted by Martin Gainty <mg...@hotmail.com>.
check out
http://jakarta.apache.org/struts/userGuide/struts-html.html#options

(I wouldnt use collection in this case..I assume we are returning scalar
entity)
to paraphrase
"where  collection of values actually selected depends on the presence or
absence of the name and property attributes"
the name or property being null can be tested and value assigned can be
ascertained.
Keep me informed,
-Martin
----- Original Message ----- 
From: "Marc Dugger" <ma...@socotech.com>
To: <st...@jakarta.apache.org>
Sent: Saturday, October 18, 2003 12:35 PM
Subject: populating form fields from request params


> I am using the same form to both create and update database entities.  The
> following is an example of a form field:
>
> <html-el:select property='documentStatusTypeId'
> value='${note.auditIdentity.documentStatusType.id}'
> onchange="editNoteForm.action=''; editNoteForm.submit(); return true;">
> <html:options collection='<%=ContextKey.DOCUMENT_STATUS_TYPES%>'
> property='id' labelProperty='name' />
> </html-el:select>
>
> And from my struts-config.xml:
>
> <form-bean name="editNoteForm"
> type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
>           <form-property name="noteId" type="java.lang.Integer" />
>           <form-property name="documentStatusTypeId"
> type="java.lang.Integer" />
> ... yada, yada, yada ...
> </form-bean>
>
> As you can see, if this field changes the page is reloaded.  Problem:  if
> ${note.auditIdentity} returns null (which would be the case if I was
> creating a new entity) the property is not being populated from form bean.
> How do I specify that if value is <null>, populate from form bean's
> property?
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.525 / Virus Database: 322 - Release Date: 10/9/2003
>
>
> ---------------------------------------------------------------------
> 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