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]