1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
la page jsp
<html:form action="admin/groupaction">
<html:radio property="actionradio" value="priv" />
<html:radio property="actionradio" value="util" />
<html:link href="groupaction.do">monLien</html:link>
</html:form>
le fichier xml
<action input="/admin/groupe.jsp" name="ActionFormGroupe" path="/admin/groupaction" scope="request" type="com.myapp.struts.ActionGroupeTraitement">
<forward name="success" path="/admin/privilegeDuGroupe.jsp"/>
</action>
la classe actionform
public class ActionFormGroupe extends org.apache.struts.action.ActionForm {
private String actionradio;
public String getActionradio() {
return actionradio;
}
public void setActionradio(String string) {
actionradio = string;
}
public ActionFormGroupe() {
super();
// TODO Auto-generated constructor stub
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (getActionradio() == null || getActionradio().length() < 1) {
BeanGroupe g=new BeanGroupe();
request.setAttribute("BeanGroupe",g);
errors.add("name", new ActionMessage("error.name.required"));
// TODO: add 'error.name.required' key to your resources
}
return errors;
}
} |
Partager