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:
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 :
- set default values in action class itself. ( don't want java deal view)
- use "s:if" tags in jsp differentiate between create , edit.
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
Post a Comment