You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Patton <da...@mymobile.info> on 2003/03/04 23:06:05 UTC

of question

What exactly does the <set-property> tag of the <form-property> tag in
the struts-config file do.  My understanding is that it can pass or set
properties within the corresponding <form-property> tag class?

Here is a scenario that I am not sure Struts can do? The thought is to
have struts dynamically populate a dropdown menu from a specified
datasource and using a DynaActionForm.  Please correct me if I am
mistaken.

On a jsp page there is a form with 1 dropdown menu element (simple form
for brevity sake). You have a DynaActionForm to mirror jsp form.  It is
configured in struts-config as follows:

<form-bean name="MyForm" dynamic="true" type="MyDynaActionForm">
            <form-property name="MyDropDownMenu" type="MyDropDownList">
                    <set-property property="listSource"
value="SomeDataSource" />
            </form-property>
</form-bean>

You also have a MyDropDownList object that looks like


public class MyDropDownList extends java.util.List
{
    private String listSource = ""; 

    public void setListSource(String listSource)
    {
        ...Some code....
    }

    public String getListSource()
    {
        ...Some code....
    }

    public void populateList()
    {
        ... code to get the list values from the specified list source
....

    } 
}

In the jsp page:

<html:select name="MyDropDownMenu">
    <html:options property="MyDropDownMenu"/> 
</html:select>

Is this correct?  Can this be donw?  Is ther another better way of
accomplishing this?

Dave Patton


Re: of question

Posted by alexj <al...@freesurf.ch>.
I don't know any other method :(

--
Alexandre Jaquet

----- Original Message -----
From: "Dave Patton" <da...@mymobile.info>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, March 04, 2003 11:18 PM
Subject: Re: <set-property> of <form-property> question


> But what if I want to specify a different datasource without hardwiring
> it into the code.  Can I, or should I, use the <set-property> tag to do
> that?
>
> On Tue, 2003-03-04 at 14:13, alexj wrote:
>
> > I don't would say it's a really good way to do but how I do that is to
> > have in my ActionForm bean getter and setter as just usual but
> > in my getter method I made an external call to an HelperAction who
> > just retrieve the datas I want to populate.
> >
> > Example
> >
> > class foo extends ActionForm {
> >
> >  private Collection fooList;
> >
> >  private String fooItem;
> >
> > ..
> >
> > public Collection getFooList () {
> >     fooList = HelperFooAction.getFooList ();
> >    return fooList;
> > }
> >
> > --
> > Alexandre Jaquet
> >
> > ----- Original Message -----
> > From: "Dave Patton" <da...@mymobile.info>
> > To: <st...@jakarta.apache.org>
> > Sent: Tuesday, March 04, 2003 11:06 PM
> > Subject: <set-property> of <form-property> question
> >
> >
> > > What exactly does the <set-property> tag of the <form-property> tag in
> > > the struts-config file do.  My understanding is that it can pass or
set
> > > properties within the corresponding <form-property> tag class?
> > >
> > > Here is a scenario that I am not sure Struts can do? The thought is to
> > > have struts dynamically populate a dropdown menu from a specified
> > > datasource and using a DynaActionForm.  Please correct me if I am
> > > mistaken.
> > >
> > > On a jsp page there is a form with 1 dropdown menu element (simple
form
> > > for brevity sake). You have a DynaActionForm to mirror jsp form.  It
is
> > > configured in struts-config as follows:
> > >
> > > <form-bean name="MyForm" dynamic="true" type="MyDynaActionForm">
> > >             <form-property name="MyDropDownMenu"
type="MyDropDownList">
> > >                     <set-property property="listSource"
> > > value="SomeDataSource" />
> > >             </form-property>
> > > </form-bean>
> > >
> > > You also have a MyDropDownList object that looks like
> > >
> > >
> > > public class MyDropDownList extends java.util.List
> > > {
> > >     private String listSource = "";
> > >
> > >     public void setListSource(String listSource)
> > >     {
> > >         ...Some code....
> > >     }
> > >
> > >     public String getListSource()
> > >     {
> > >         ...Some code....
> > >     }
> > >
> > >     public void populateList()
> > >     {
> > >         ... code to get the list values from the specified list source
> > > ....
> > >
> > >     }
> > > }
> > >
> > > In the jsp page:
> > >
> > > <html:select name="MyDropDownMenu">
> > >     <html:options property="MyDropDownMenu"/>
> > > </html:select>
> > >
> > > Is this correct?  Can this be donw?  Is ther another better way of
> > > accomplishing this?
> > >
> > > Dave Patton
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
> _________________________________
> David H. Patton
> dave@mymobile.info
> (202) 276-8998 - pcs
>
> -----BEGIN PGP PUB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uoRe13CzGWyhNQafV1gMcpBx9KxNi24UowJiT+cJpnxMCu
> +DNElC2AmG7phPagSFL8F4f++dGL2l8kAkxCSCl3Kr+8HUlFmOwwZ1PGSSM83pM/
> NNZKDAdGUiBRKqC32oOhKacxb6cf4ta1kZ6GDZcqVo+5qlz4OtUKbRLtW5Y8tiFc
> PwkDePX/F1490V3YWgHVzwARAQABiQEiBBgBAgAMBQI7ouqNBRsMAAAAAAoJEOWQ
> 5D6nisB/8xsIAJLNUQC8SOQF5txBrO22W7uAJ9xU9RK66Pyf9a+KjdNf4rE6vK4n
> vhbSGmtoPB4bzOQ9RKpo8ihBQp1cY9mLnwuJDKSuzpkaOK5pd+bifwY20tweULR6
> 4rtU8uLL1H0eom2IBjSXhf4n8DEdyrGKKHYNO/GRLx/UHHcLEFvz+4buHrCPoiBP
> JwjS/Ifg5xc3nTJnZmG2HzapoRwgXxGitbNTArUZWkqHYLygA1/ilmnFs8POj/s+
> TD4wSuDlrwE2CE2O8XbRuRVPryzn8mXXdZ1pSwrrvZjRU5rnDRAOqhHZQQbudVd3
> XvnDDBDoURSqwDqnwOkoOSTC95aj+vy5WW0=
> =/zoc
>
> -----END PGP PUBLIC KEY BLOCK-----
>



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


Re: of question

Posted by Dave Patton <da...@mymobile.info>.
But what if I want to specify a different datasource without hardwiring
it into the code.  Can I, or should I, use the <set-property> tag to do
that?

On Tue, 2003-03-04 at 14:13, alexj wrote:

> I don't would say it's a really good way to do but how I do that is to
> have in my ActionForm bean getter and setter as just usual but
> in my getter method I made an external call to an HelperAction who
> just retrieve the datas I want to populate.
> 
> Example 
> 
> class foo extends ActionForm {
> 
>  private Collection fooList;
> 
>  private String fooItem;
> 
> ..
> 
> public Collection getFooList () {
>     fooList = HelperFooAction.getFooList ();
>    return fooList;
> }
> 
> --
> Alexandre Jaquet
> 
> ----- Original Message ----- 
> From: "Dave Patton" <da...@mymobile.info>
> To: <st...@jakarta.apache.org>
> Sent: Tuesday, March 04, 2003 11:06 PM
> Subject: <set-property> of <form-property> question
> 
> 
> > What exactly does the <set-property> tag of the <form-property> tag in
> > the struts-config file do.  My understanding is that it can pass or set
> > properties within the corresponding <form-property> tag class?
> > 
> > Here is a scenario that I am not sure Struts can do? The thought is to
> > have struts dynamically populate a dropdown menu from a specified
> > datasource and using a DynaActionForm.  Please correct me if I am
> > mistaken.
> > 
> > On a jsp page there is a form with 1 dropdown menu element (simple form
> > for brevity sake). You have a DynaActionForm to mirror jsp form.  It is
> > configured in struts-config as follows:
> > 
> > <form-bean name="MyForm" dynamic="true" type="MyDynaActionForm">
> >             <form-property name="MyDropDownMenu" type="MyDropDownList">
> >                     <set-property property="listSource"
> > value="SomeDataSource" />
> >             </form-property>
> > </form-bean>
> > 
> > You also have a MyDropDownList object that looks like
> > 
> > 
> > public class MyDropDownList extends java.util.List
> > {
> >     private String listSource = ""; 
> > 
> >     public void setListSource(String listSource)
> >     {
> >         ...Some code....
> >     }
> > 
> >     public String getListSource()
> >     {
> >         ...Some code....
> >     }
> > 
> >     public void populateList()
> >     {
> >         ... code to get the list values from the specified list source
> > ....
> > 
> >     } 
> > }
> > 
> > In the jsp page:
> > 
> > <html:select name="MyDropDownMenu">
> >     <html:options property="MyDropDownMenu"/> 
> > </html:select>
> > 
> > Is this correct?  Can this be donw?  Is ther another better way of
> > accomplishing this?
> > 
> > Dave Patton
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org



_________________________________
David H. Patton
dave@mymobile.info
(202) 276-8998 - pcs

-----BEGIN PGP PUBLIC KEY BLOCK----- 

Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com> 

mQENBDui6osBCADP9OqVftQ2qxZz2fsxEf6GT6V2Fu0c2iIIMeWGyc5Pwl+xXe2w 
3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oOhKacxb6cf4ta1kZ6GDZcqVo+5qlz4OtUKbRLtW5Y8tiFc 
PwkDePX/F1490V3YWgHVzwARAQABiQEiBBgBAgAMBQI7ouqNBRsMAAAAAAoJEOWQ 
5D6nisB/8xsIAJLNUQC8SOQF5txBrO22W7uAJ9xU9RK66Pyf9a+KjdNf4rE6vK4n 
vhbSGmtoPB4bzOQ9RKpo8ihBQp1cY9mLnwuJDKSuzpkaOK5pd+bifwY20tweULR6 
4rtU8uLL1H0eom2IBjSXhf4n8DEdyrGKKHYNO/GRLx/UHHcLEFvz+4buHrCPoiBP 
JwjS/Ifg5xc3nTJnZmG2HzapoRwgXxGitbNTArUZWkqHYLygA1/ilmnFs8POj/s+ 
TD4wSuDlrwE2CE2O8XbRuRVPryzn8mXXdZ1pSwrrvZjRU5rnDRAOqhHZQQbudVd3 
XvnDDBDoURSqwDqnwOkoOSTC95aj+vy5WW0= 
=/zoc 

-----END PGP PUBLIC KEY BLOCK-----

Re: of question

Posted by alexj <al...@freesurf.ch>.
I don't would say it's a really good way to do but how I do that is to
have in my ActionForm bean getter and setter as just usual but
in my getter method I made an external call to an HelperAction who
just retrieve the datas I want to populate.

Example 

class foo extends ActionForm {

 private Collection fooList;

 private String fooItem;

..

public Collection getFooList () {
    fooList = HelperFooAction.getFooList ();
   return fooList;
}

--
Alexandre Jaquet

----- Original Message ----- 
From: "Dave Patton" <da...@mymobile.info>
To: <st...@jakarta.apache.org>
Sent: Tuesday, March 04, 2003 11:06 PM
Subject: <set-property> of <form-property> question


> What exactly does the <set-property> tag of the <form-property> tag in
> the struts-config file do.  My understanding is that it can pass or set
> properties within the corresponding <form-property> tag class?
> 
> Here is a scenario that I am not sure Struts can do? The thought is to
> have struts dynamically populate a dropdown menu from a specified
> datasource and using a DynaActionForm.  Please correct me if I am
> mistaken.
> 
> On a jsp page there is a form with 1 dropdown menu element (simple form
> for brevity sake). You have a DynaActionForm to mirror jsp form.  It is
> configured in struts-config as follows:
> 
> <form-bean name="MyForm" dynamic="true" type="MyDynaActionForm">
>             <form-property name="MyDropDownMenu" type="MyDropDownList">
>                     <set-property property="listSource"
> value="SomeDataSource" />
>             </form-property>
> </form-bean>
> 
> You also have a MyDropDownList object that looks like
> 
> 
> public class MyDropDownList extends java.util.List
> {
>     private String listSource = ""; 
> 
>     public void setListSource(String listSource)
>     {
>         ...Some code....
>     }
> 
>     public String getListSource()
>     {
>         ...Some code....
>     }
> 
>     public void populateList()
>     {
>         ... code to get the list values from the specified list source
> ....
> 
>     } 
> }
> 
> In the jsp page:
> 
> <html:select name="MyDropDownMenu">
>     <html:options property="MyDropDownMenu"/> 
> </html:select>
> 
> Is this correct?  Can this be donw?  Is ther another better way of
> accomplishing this?
> 
> Dave Patton
> 
> 


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