You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by josef richberg <sq...@yahoo.com> on 2002/03/26 16:11:34 UTC

returning the selected value from an

I have the following code snippet: 
<bean:define id="vendornames" name="ProdAddForm"
property="vname"
        type="java.util.Collection"/>

then below 
<html:select property="vname">
    <html:options collection="vendornames"
property="value"  labelProperty="label"/>
    </html:select>

I have a getter method in my Action form: 
 public Collection getVname(){
        return new DBAccess().getVendorNames();
 }

The problem is if I try to set the result of the
selection via this method in the action form: 
 public void setVname(String value){
   xxxxxx
 }

it errors with: No getter method for property vname of
bean ProdAddForm 
How do I retrieve the lone value of the select? 
--josef


__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards�
http://movies.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: returning the selected value from an

Posted by Jim Crossley <jc...@ifleet.com>.
You were quite clear in your question.  I can't see how I can be any
more clear in my answer.  :-)

It sounds like you didn't change your <bean:define> property to
"vnameList".

josef richberg <sq...@yahoo.com> writes:

> I did that, but it did not work.  It looks like it is
> now looking to get the names to populate the select
> list from the method getVname().  Maybe I was not
> clear in my question.  I have a collection object that
> is populated from a database with and id,descp.  Once
> the choice is selected I need to collect the id that
> was chosen.  I need to separate the population of the
> select with the choice made.
> 
> --josef
> --- Jim Crossley <jc...@ifleet.com> wrote:
> > Here's how I would do it.  Change the name of the
> > existing method that
> > returns a collection and add a method to get the
> > vname:
> > 
> > public Collection getVnameList(){
> >   return new DBAccess().getVendorNames();
> > }
> > public void setVname(String value){
> >   xxxxxx
> > }
> > public String getVname(){
> >   xxxxxx
> > }
> > 
> > Then change your <bean:define> property to
> > "vnameList".  That should
> > do the trick.
> > 
> > -- Jim
> > 
> > josef richberg <sq...@yahoo.com> writes:
> > 
> > > That I understand.  What I don't understand is how
> > to
> > > do that.  How can I reference the value chosen in
> > the
> > > select?  The id is tied to the bean.  
> > > 
> > > --josef
> > > --- Jim Crossley <jc...@ifleet.com> wrote:
> > > > In your formbean, you need to distinguish
> > between
> > > > the value selected
> > > > and the values able to be selected.  You've
> > > > accounted for the latter.
> > > > You need another method to account for the
> > former. 
> > > > The property
> > > > referred to in your bean:define (returning a
> > > > Collection) should not be
> > > > the same property referred to in your
> > html:select
> > > > that returns a
> > > > String.
> > > > 
> > > > -- Jim
> > > > 
> > > > josef richberg <sq...@yahoo.com> writes:
> > > > 
> > > > > I have the following code snippet: 
> > > > > <bean:define id="vendornames"
> > name="ProdAddForm"
> > > > > property="vname"
> > > > >         type="java.util.Collection"/>
> > > > > 
> > > > > then below 
> > > > > <html:select property="vname">
> > > > >     <html:options collection="vendornames"
> > > > > property="value"  labelProperty="label"/>
> > > > >     </html:select>
> > > > > 
> > > > > I have a getter method in my Action form: 
> > > > >  public Collection getVname(){
> > > > >         return new
> > DBAccess().getVendorNames();
> > > > >  }
> > > > > 
> > > > > The problem is if I try to set the result of
> > the
> > > > > selection via this method in the action form: 
> > > > >  public void setVname(String value){
> > > > >    xxxxxx
> > > > >  }
> > > > > 
> > > > > it errors with: No getter method for property
> > > > vname of
> > > > > bean ProdAddForm 
> > > > > How do I retrieve the lone value of the
> > select? 
> > > > > --josef
> > > > > 
> > > > > 
> > > > >
> > __________________________________________________
> > > > > Do You Yahoo!?
> > > > > Yahoo! Movies - coverage of the 74th Academy
> > > > Awards®
> > > > > http://movies.yahoo.com/
> > > > > 
> > > > > --
> > > > > To unsubscribe, e-mail:  
> > > >
> > <ma...@jakarta.apache.org>
> > > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > 
> > > > --
> > > > To unsubscribe, e-mail:  
> > > >
> > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > > <ma...@jakarta.apache.org>
> > > > 
> > > 
> > > 
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Movies - coverage of the 74th Academy
> > Awards®
> > > http://movies.yahoo.com/
> > > 
> > > --
> > > To unsubscribe, e-mail:  
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > 
> > --
> > To unsubscribe, e-mail:  
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Movies - coverage of the 74th Academy Awards®
> http://movies.yahoo.com/
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: returning the selected value from an

Posted by josef richberg <sq...@yahoo.com>.
I did that, but it did not work.  It looks like it is
now looking to get the names to populate the select
list from the method getVname().  Maybe I was not
clear in my question.  I have a collection object that
is populated from a database with and id,descp.  Once
the choice is selected I need to collect the id that
was chosen.  I need to separate the population of the
select with the choice made.

--josef
--- Jim Crossley <jc...@ifleet.com> wrote:
> Here's how I would do it.  Change the name of the
> existing method that
> returns a collection and add a method to get the
> vname:
> 
> public Collection getVnameList(){
>   return new DBAccess().getVendorNames();
> }
> public void setVname(String value){
>   xxxxxx
> }
> public String getVname(){
>   xxxxxx
> }
> 
> Then change your <bean:define> property to
> "vnameList".  That should
> do the trick.
> 
> -- Jim
> 
> josef richberg <sq...@yahoo.com> writes:
> 
> > That I understand.  What I don't understand is how
> to
> > do that.  How can I reference the value chosen in
> the
> > select?  The id is tied to the bean.  
> > 
> > --josef
> > --- Jim Crossley <jc...@ifleet.com> wrote:
> > > In your formbean, you need to distinguish
> between
> > > the value selected
> > > and the values able to be selected.  You've
> > > accounted for the latter.
> > > You need another method to account for the
> former. 
> > > The property
> > > referred to in your bean:define (returning a
> > > Collection) should not be
> > > the same property referred to in your
> html:select
> > > that returns a
> > > String.
> > > 
> > > -- Jim
> > > 
> > > josef richberg <sq...@yahoo.com> writes:
> > > 
> > > > I have the following code snippet: 
> > > > <bean:define id="vendornames"
> name="ProdAddForm"
> > > > property="vname"
> > > >         type="java.util.Collection"/>
> > > > 
> > > > then below 
> > > > <html:select property="vname">
> > > >     <html:options collection="vendornames"
> > > > property="value"  labelProperty="label"/>
> > > >     </html:select>
> > > > 
> > > > I have a getter method in my Action form: 
> > > >  public Collection getVname(){
> > > >         return new
> DBAccess().getVendorNames();
> > > >  }
> > > > 
> > > > The problem is if I try to set the result of
> the
> > > > selection via this method in the action form: 
> > > >  public void setVname(String value){
> > > >    xxxxxx
> > > >  }
> > > > 
> > > > it errors with: No getter method for property
> > > vname of
> > > > bean ProdAddForm 
> > > > How do I retrieve the lone value of the
> select? 
> > > > --josef
> > > > 
> > > > 
> > > >
> __________________________________________________
> > > > Do You Yahoo!?
> > > > Yahoo! Movies - coverage of the 74th Academy
> > > Awards�
> > > > http://movies.yahoo.com/
> > > > 
> > > > --
> > > > To unsubscribe, e-mail:  
> > >
> <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > 
> > > --
> > > To unsubscribe, e-mail:  
> > >
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > 
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Movies - coverage of the 74th Academy
> Awards�
> > http://movies.yahoo.com/
> > 
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards�
http://movies.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: returning the selected value from an

Posted by Jim Crossley <jc...@ifleet.com>.
Here's how I would do it.  Change the name of the existing method that
returns a collection and add a method to get the vname:

public Collection getVnameList(){
  return new DBAccess().getVendorNames();
}
public void setVname(String value){
  xxxxxx
}
public String getVname(){
  xxxxxx
}

Then change your <bean:define> property to "vnameList".  That should
do the trick.

-- Jim

josef richberg <sq...@yahoo.com> writes:

> That I understand.  What I don't understand is how to
> do that.  How can I reference the value chosen in the
> select?  The id is tied to the bean.  
> 
> --josef
> --- Jim Crossley <jc...@ifleet.com> wrote:
> > In your formbean, you need to distinguish between
> > the value selected
> > and the values able to be selected.  You've
> > accounted for the latter.
> > You need another method to account for the former. 
> > The property
> > referred to in your bean:define (returning a
> > Collection) should not be
> > the same property referred to in your html:select
> > that returns a
> > String.
> > 
> > -- Jim
> > 
> > josef richberg <sq...@yahoo.com> writes:
> > 
> > > I have the following code snippet: 
> > > <bean:define id="vendornames" name="ProdAddForm"
> > > property="vname"
> > >         type="java.util.Collection"/>
> > > 
> > > then below 
> > > <html:select property="vname">
> > >     <html:options collection="vendornames"
> > > property="value"  labelProperty="label"/>
> > >     </html:select>
> > > 
> > > I have a getter method in my Action form: 
> > >  public Collection getVname(){
> > >         return new DBAccess().getVendorNames();
> > >  }
> > > 
> > > The problem is if I try to set the result of the
> > > selection via this method in the action form: 
> > >  public void setVname(String value){
> > >    xxxxxx
> > >  }
> > > 
> > > it errors with: No getter method for property
> > vname of
> > > bean ProdAddForm 
> > > How do I retrieve the lone value of the select? 
> > > --josef
> > > 
> > > 
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Movies - coverage of the 74th Academy
> > Awards®
> > > http://movies.yahoo.com/
> > > 
> > > --
> > > To unsubscribe, e-mail:  
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > 
> > --
> > To unsubscribe, e-mail:  
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Movies - coverage of the 74th Academy Awards®
> http://movies.yahoo.com/
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: returning the selected value from an

Posted by josef richberg <sq...@yahoo.com>.
That I understand.  What I don't understand is how to
do that.  How can I reference the value chosen in the
select?  The id is tied to the bean.  

--josef
--- Jim Crossley <jc...@ifleet.com> wrote:
> In your formbean, you need to distinguish between
> the value selected
> and the values able to be selected.  You've
> accounted for the latter.
> You need another method to account for the former. 
> The property
> referred to in your bean:define (returning a
> Collection) should not be
> the same property referred to in your html:select
> that returns a
> String.
> 
> -- Jim
> 
> josef richberg <sq...@yahoo.com> writes:
> 
> > I have the following code snippet: 
> > <bean:define id="vendornames" name="ProdAddForm"
> > property="vname"
> >         type="java.util.Collection"/>
> > 
> > then below 
> > <html:select property="vname">
> >     <html:options collection="vendornames"
> > property="value"  labelProperty="label"/>
> >     </html:select>
> > 
> > I have a getter method in my Action form: 
> >  public Collection getVname(){
> >         return new DBAccess().getVendorNames();
> >  }
> > 
> > The problem is if I try to set the result of the
> > selection via this method in the action form: 
> >  public void setVname(String value){
> >    xxxxxx
> >  }
> > 
> > it errors with: No getter method for property
> vname of
> > bean ProdAddForm 
> > How do I retrieve the lone value of the select? 
> > --josef
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Movies - coverage of the 74th Academy
> Awards�
> > http://movies.yahoo.com/
> > 
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards�
http://movies.yahoo.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: returning the selected value from an

Posted by Jim Crossley <jc...@ifleet.com>.
In your formbean, you need to distinguish between the value selected
and the values able to be selected.  You've accounted for the latter.
You need another method to account for the former.  The property
referred to in your bean:define (returning a Collection) should not be
the same property referred to in your html:select that returns a
String.

-- Jim

josef richberg <sq...@yahoo.com> writes:

> I have the following code snippet: 
> <bean:define id="vendornames" name="ProdAddForm"
> property="vname"
>         type="java.util.Collection"/>
> 
> then below 
> <html:select property="vname">
>     <html:options collection="vendornames"
> property="value"  labelProperty="label"/>
>     </html:select>
> 
> I have a getter method in my Action form: 
>  public Collection getVname(){
>         return new DBAccess().getVendorNames();
>  }
> 
> The problem is if I try to set the result of the
> selection via this method in the action form: 
>  public void setVname(String value){
>    xxxxxx
>  }
> 
> it errors with: No getter method for property vname of
> bean ProdAddForm 
> How do I retrieve the lone value of the select? 
> --josef
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Movies - coverage of the 74th Academy Awards®
> http://movies.yahoo.com/
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>