Hello: We are in the middle of our struts implementation, and have run into a situation that we feel must have been solved by someone already -- one of those "wow, someone must have had this come up before" moments. :)
We have a search form that allows the user to populate several fields, submit the form, and get some results. This is a fairly trivial struts implementation-- we have a (OrderSearchForm) and an OrderSearchAction that handles the results. When the users clicks "submit" on the form, all is well -- inputs are redisplayed, etc. The rub comes in due to some hyperlinks we have on the same page ( in the navigation bar ) that allows the user to change languages. When these links are clicked, we need to refresh the current page ( with all the search results and form fields still populated). One solution would be to make the bean Session scoped, but our functionality requirements will not allow that because users that use the back button will get confusing results. Specifically, if the user does a search, then gets the results, then clicks the back button, the Session scoped bean will contain the most recent search parameters and the user would see the old ones, so they'd <appear> to be getting the new results in response to the old request criteria. Disabling the back button by using transaction tokens is out, because unfortunately our users _love_ the back button :( To make our site friendlier for back button use, we'd like to persist the state of the form onto these hyperlinks, so that we dont have the session back button problems. We read the struts docs and archives, and at this point the best we can come up with would be to have a formbean method like this: public class OrderForm extends ActionForm{ public String getOrderNumber() public void setOrderNumber( String onumber) public String getSearchStatus() public void setSearchStatus( String status ) Map getUrlParameters(){ ... } } the extra getUrlParameters() method could be used by <html:link> to add the pararmeters necessary to persist the form data. What bothers us about this approach is that we are essentially re-inventing the logic used to map a ActionForm into request parameters. This is fairly trivial for single beans, but certainly non-trivial for indexed properites, mapped properties, and nested beans. We'd like to be able to use the same action ("OrderSearchAction" ) to process the request coming from a link as we do for the OrderSearch form. This means that the <html:link> will need to have the same parameter names that struts uses when the <html:input> and <html:form> tags are used. We couldnt help but think that there should be some way to build a hyperlink that will add all of the url parameters for a form onto the url string using parameter naming scheme that is identical to that used by <html:form>. For example, if I have this form bean: public class OrderForm extends ActionForm{ public String getOrderNumber() public void setOrderNumber( String onumber) public String getSearchStatus() public void setSearchStatus( String status ) } And this action configuration: <action path="/ordersearchaction" type="com.mycorp.OrderSearchAction" name="orderform" scope="request" validate="true" <forward name="pricingEntry" path="/WEB-INF/jsp/pricingEntry.jsp"/> </action> I'd like something like this: <html:link action="ordersearchaction" bean="mybean">Click here</html:link> to create this href: <a href="/do/ordersearchaction&ordernumber=123454&searchstatus=open">Click here</a> Are we totally off-base here? Is there a simpler solution we are missing? Comments are appreciated! We're expecting that there's an easy way to do this, but if there isnt and this seems valuable, we'd be happy to contribute an implementation to the group! Regards Dave __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]