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. > http://promotions.yahoo.com/new_mail > > --------------------------------------------------------------------- > 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] > > __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]