OKay, you caught my mistake. But, 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: > 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. > > > > > > > === message truncated === __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]