Why does one line have getproperty and the other have getProperty ???  Both
should read getProperty ;-)

Chris

----- Original Message -----
From: "Caroline Jen" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, June 16, 2004 11:36 PM
Subject: Re: The Same Action With and Without a Form


> I am confused.
>
> First, the compiler complains about the statements:
>  String sort = BeanUtils.getproperty( form, "sort" );
>  String order = BeanUtils.getProperty( form, "order"
> );
>
> error:
> cannot resolve symbol
> symbol: method getProperty
>
> Note: I did
> import org.apache.commons.beanutils.BeanUtils;
>
> Second, I already have
>
>       String sort  = request.getParameter( "sort" );
>       String order = request.getParameter( "order" );
>
> in my servlet that extends Action.  'sort' and 'order'
> have been defined.  I cannot add:
>
>  String sort = BeanUtils.getproperty( form, "sort" );
>  String order = BeanUtils.getProperty( form, "order"
> );
>
> -Caroline
> --- Chris Cranford <[EMAIL PROTECTED]>
> wrote:
> > Correction to the two BeanUtils calls, it should be:
> >     String sort =
> > BeanUtils.getProperty(form,"sort");
> >     String order = BeanUtils.getPropety(form,
> > "order");
> >
> > But in either case it would yield the same result
> > :-)
> > Chris
> >
> > ----- Original Message -----
> > From: "Chris Cranford"
> > <[EMAIL PROTECTED]>
> > To: "Struts Users Mailing List"
> > <[EMAIL PROTECTED]>
> > Sent: Wednesday, June 16, 2004 7:25 PM
> > Subject: Re: The Same Action With and Without a Form
> >
> >
> > > Hmm, checkin' something here :-)
> > >
> > > I defined a form just like the following form is
> > defined below.  I then
> > > defined an action mapping as follows:
> > >
> > > <action
> > >     path="/searchtest"
> > >     type="com.setech.test.ChrisTestAction"
> > >     scope="request"
> > >     name="mySearchForm">
> > >     <forward name="success"
> > path="/pages/cctest.jsp" />
> > > </action>
> > >
> > > Then in my ChrisTestAction executeAction function,
> > I did the following:
> > >
> > >     String sort =
> > BeanUtils.getSimpleProperty(form,"sort");
> > >     String order =
> > BeanUtils.getSimpleProperty(form, "order");
> > >
> > >     Log log =
> > LogFactory.getLog(ChrisTestAction.class);
> > >     if(log.isDebugEnabled())
> > log.debug("sort="+sort+",order="+order);
> > >
> > > I checked my tomcat output and both values were in
> > fact populated.
> > >
> > > Then in my JSP, I can use javascript to alter 2
> > hidden fields that
> > represent
> > > the sort/order values when a user clicks on an
> > icon or column header and
> > > then submit the form again to the action to handle
> > updating the view based
> > > on the new sort/order values.  Alternatively, I
> > could build the URL for
> > each
> > > link/image dynamically like:
> > >
> > > /searchtest.do?sort=X&order=Y
> > >
> > > but /searchtest.do does imply setting
> > sort=postDate and order=DESC if
> > > they're not supplied by the request to the action
> > :-)...
> > >
> > > How does your struts-config.xml look?  What about
> > your JSP ?
> > >
> > > ----- Original Message -----
> > > From: "Caroline Jen" <[EMAIL PROTECTED]>
> > > To: "Struts Users Mailing List"
> > <[EMAIL PROTECTED]>
> > > Sent: Wednesday, June 16, 2004 5:58 PM
> > > Subject: RE: The Same Action With and Without a
> > Form
> > >
> > >
> > > > The property of the 'initial' attribute inside
> > the
> > > > <form-property ....> tag (i.e.
> > initial="postDate")
> > > > does not seem to become the default value.  The
> > query
> > > > method (with sort and order among the
> > parameters) that
> > > > retrieve articles from the database got the
> > > > NullPointerException.
> > > >
> > > > I know the query method works well because there
> > is no
> > > > problem when I perform the action with a form.
> > > >
> > > > -Caroline
> > > >
> > > > --- "CRANFORD, CHRIS"
> > <[EMAIL PROTECTED]>
> > > > wrote:
> > > > > Define your form in struts-config.xml like:
> > > > >
> > > > > <form-bean
> > > > >   name="mySearchForm"
> > > > >
> > type="org.apache.struts.action.DynaActionForm">
> > > > >   <form-property
> > > > >     name="sort"
> > > > >     initial="postDate"
> > > > >     type="java.lang.String"/>
> > > > >   <form-property
> > > > >     name="order"
> > > > >     initial="DESC"
> > > > >     type="java.lang.String"/>
> > > > >   .. Other properties here
> > > > > </form-bean>
> > > > >
> > > > > Then define your action mapping to use this
> > > > > formbean.  When your form posts,
> > > > > it will assume the default values for
> > sort/order if
> > > > > they not present in the
> > > > > request.  If they're present in the
> > HttpRequest
> > > > > object, then the form is
> > > > > populated with whatever values are coming from
> > the
> > > > > request.
> > > > >
> > > > > Hope this helps.
> > > > > Chris
> > > > >
> > > > > -----Original Message-----
> > > > > From: Caroline Jen
> > [mailto:[EMAIL PROTECTED]
> > > > > Sent: Wednesday, June 16, 2004 12:40 PM
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: The Same Action With and Without a
> > Form
> > > > >
> > > > >
> > > > > I have a "list" of articles to be retrieved
> > from the
> > > > > database and displayed.
> > > > >
> > > > > The first time I display the list, I simply
> > sort the
> > > > > list by posting date and descending order
> > (without
> > > > > providing a form) when I query the database.
> > > > >
> > > > > Thereafter, users are offered opportunities on
> > top
> > > > > of
> > > > > the table of the list to choose 'sort'
> > criteria from
> > > > > a
> > > > > drop down menu and to choose 'order', which is
> > > > > either
> > > > > ascending or descending, with a GO button.
> > That is
> > > > > to
> > > > > say, the same action (ListArticles) is called
> > with a
> > > > > 'form' consisting of two menus.
> > > > >
> > > > > In my Java class that extends Action, I did
> > the
> > > > > following:
> > > > >
> > > > >      String sort  = request.getParameter(
> > "sort" );
> > > > >      String order = request.getParameter(
> > "order" );
> > > > >      if ( sort.length() == 0 ) sort =
> > "PostDate";
> > > > >      if ( order.length()== 0 ) order = "DESC";
> > > > >
> > > > > I do not know how to handle the name attribute
> > of
> > > > > the
> > > > > <action .... /> tag in the struts-config.xml.
> > > > >
> > > > > Those are the same action.  There is actually
> > an
> > > > > empty
> > > > > form the first time the action is called.  And
> > there
> > > > > is a form consisting of two menus the second
> > time
> > > > > the
> > > > > action is called.
> > > > >
> > > > > I need your instructions and help.
> > > > >
> > > > >
> > > > >
> > > > > __________________________________
> > > > > Do you Yahoo!?
> > > > > Yahoo! Mail - Helps protect you from nasty
> > viruses.
> >
> === message truncated ===
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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

Reply via email to