struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "leonZ" <leons...@netease.com>
Subject Re: How can I set the defualt selection?
Date Wed, 09 Jul 2003 01:39:39 GMT
example.jsp code segment:
...
<input type="hidden" name="submit_flag" value="1">
<html:select property="type">
<html:option value="1">1</html:option>
<html:option value="2">2</html:option>
<html:option value="3">3</html:option>
</html:select>
...

Don't forget adding the set and get method for submit_flag to the
exampleForm.java

exampleAction.java code segment:
...
public ActionForward perform(ActionMapping actionMapping, ActionForm
actionForm, HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse) {
        MessageResources messages = getResources();
        Locale locale = getLocale(httpServletRequest);
        String flag =
httpServletRequest.getParameter("submit_flag")==null?"":httpServletRequest.g
etParameter("submit_flag");
        if(flag.equals("")){
            ( (exampleForm) actionForm).setType("2");  /** set the defualt
selection **/
            return (new ActionForward(actionMapping.getInput()));   /**
here the example.jsp will be show  **/
        }
......
...
}

and you have to visit the exampleAction(something like exampleAction.do)
instead of example.jsp for the webpage view.

that's my solution, I hope it will be helpful.






---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message