struts2 - using same jsp page for create and edit struts 2 -


i want use same jsp page create , edit operations. there 2 challenges in inter-related:

  1. in jsp, want of fields have default value. here sample code better understanding

    public class nodeaction extends actionsupport{       string nodeid;     public string createnode(){...};     public string addnode(){...};     public string editnode(){....};     public string updatenode(){....}; }  

    this jsp content: <s:textfield name="nodeid" value="127.0.0.1>

    now same jsp needs used above functions.

    you cannot use "value" attribute of tag set default value because while editing, page show default value instead of actual value. there 2 ways of solving :

    1. set default values in action class itself. ( don't want java deal view)
    2. use "s:if" tags in jsp differentiate between create , edit.
  2. the second challenge when use same jsp edit action followed update action , create action followed add action.

    so when submitting page(there 1 submit button), next action (update, add) needs determined. again solution have action class variable , hidden field in jsp , use value of hidden field determine next action.

what best ways deal problems. don't want use different jsps.


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -