You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by AMIR-TAHMASSEB Marc <MA...@cus-strasbourg.net> on 2003/01/06 15:14:58 UTC
Multibox and setter problem
Hi everybody (and happy new year :-)
I have a jsp page with multibox. When i check some boxes and submit the
form, then setter of my form is never used ! So i can not get the selected
values, Can anybody help me please ?
I'm using Struts 1.02
thanks for you help,
Marc
Here are my codes :
_______________struts-config.xml :
...
<form-beans>
<form-bean name="exportUtilsForm"
type="cus.baza.action.ExportUtilsForm"/>
...
</form-beans>
....
<global-forwards>
<forward name="choix_export_util" path="/choix_export_util.jsp"/>
...
</global-forwards>
...
<action-mappings>
<action path="/realExportUtil"
type="cus.baza.action.RealiserExportUtilAction"
name="exportUtilsForm"
scope="request"/>
...
</action-mappings>
...
_______________JSP : choix_export_util.jsp:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
...
<html:form action="/realExportUtil.do" name="exportUtilsForm"
type="cus.baza.action.ExportUtilsForm">
...
<logic:iterate id="annuaire" property="annuaires" name="exportUtilsForm">
<tr align="left">
<td width="100%">
<html:multibox property="selectedAnnuaires">
<bean:write name="annuaire"/>
</html:multibox>
<bean:write name="annuaire"/>
</td>
</tr>
</logic:iterate>
...
</html:form>
_______________ActionForm: ExportUtilsForm.java :
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
public class ExportUtilsForm extends ActionForm {
protected String[] selectedAnnuaires = new String[0]; //{"REF"};
protected String[] annuaires = {"REF", "SIGAGIP", "NT", "EXCHANGE",
"INMS", "TEL", "ORACLE"};
public String[] getSelectedAnnuaires() {
return selectedAnnuaires;
}
public void setSelectedAnnuaires(String[] selectedAnnuaires) {
System.out.println("--------------------->
ExportUtilsForm.setSelectedAnnuaires(selectedAnnuaires)");
this.selectedAnnuaires = selectedAnnuaires;
}
public String[] getAnnuaires() {
return annuaires;
}
public void setAnnuaires(String[] annuaires) {
this.annuaires=annuaires;
}
public void reset(ActionMapping mapping, HttpServletRequest request) {
selectedAnnuaires = new String[0];
annuaires = new String[] {"REF", "SIGAGIP", "NT", "EXCHANGE", "INMS",
"TEL", "ORACLE"};
}
_______________Perfom :
String[] selectedAnnuaires = form.getSelectedAnnuaires();
for (int i=0; i<selectedAnnuaires.length; i++) {
System.out.println("\t\t"+i+" : "+selectedAnnuaires[i]); // Here i
obtain a zero for the length of the array....
}
URL to Download the tiles-blank-struts1-0.war
Posted by ashokd <as...@visualsoft-tech.com>.
Hi,
>From where I can download the "tiles-blank-struts1-0.war ".
Can any one hlep me in this.
Thanks & Regards,
Ashok.D
----- Original Message -----
From: "AMIR-TAHMASSEB Marc" <MA...@cus-strasbourg.net>
To: <st...@jakarta.apache.org>
Sent: Monday, January 06, 2003 7:44 PM
Subject: Multibox and setter problem
> Hi everybody (and happy new year :-)
>
> I have a jsp page with multibox. When i check some boxes and submit the
> form, then setter of my form is never used ! So i can not get the selected
> values, Can anybody help me please ?
> I'm using Struts 1.02
>
> thanks for you help,
>
> Marc
>
> Here are my codes :
>
>
> _______________struts-config.xml :
> ...
> <form-beans>
> <form-bean name="exportUtilsForm"
> type="cus.baza.action.ExportUtilsForm"/>
> ...
> </form-beans>
> ....
> <global-forwards>
> <forward name="choix_export_util" path="/choix_export_util.jsp"/>
> ...
> </global-forwards>
> ...
> <action-mappings>
> <action path="/realExportUtil"
> type="cus.baza.action.RealiserExportUtilAction"
> name="exportUtilsForm"
> scope="request"/>
> ...
> </action-mappings>
> ...
>
>
> _______________JSP : choix_export_util.jsp:
>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
> ...
> <html:form action="/realExportUtil.do" name="exportUtilsForm"
> type="cus.baza.action.ExportUtilsForm">
> ...
> <logic:iterate id="annuaire" property="annuaires" name="exportUtilsForm">
> <tr align="left">
> <td width="100%">
> <html:multibox property="selectedAnnuaires">
> <bean:write name="annuaire"/>
> </html:multibox>
> <bean:write name="annuaire"/>
> </td>
> </tr>
> </logic:iterate>
> ...
> </html:form>
>
> _______________ActionForm: ExportUtilsForm.java :
>
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionMapping;
> import javax.servlet.http.HttpServletRequest;
>
> public class ExportUtilsForm extends ActionForm {
>
> protected String[] selectedAnnuaires = new String[0]; //{"REF"};
> protected String[] annuaires = {"REF", "SIGAGIP", "NT", "EXCHANGE",
> "INMS", "TEL", "ORACLE"};
> public String[] getSelectedAnnuaires() {
> return selectedAnnuaires;
> }
>
> public void setSelectedAnnuaires(String[] selectedAnnuaires) {
> System.out.println("--------------------->
> ExportUtilsForm.setSelectedAnnuaires(selectedAnnuaires)");
> this.selectedAnnuaires = selectedAnnuaires;
> }
>
> public String[] getAnnuaires() {
> return annuaires;
> }
>
> public void setAnnuaires(String[] annuaires) {
> this.annuaires=annuaires;
> }
>
> public void reset(ActionMapping mapping, HttpServletRequest request) {
> selectedAnnuaires = new String[0];
> annuaires = new String[] {"REF", "SIGAGIP", "NT", "EXCHANGE",
"INMS",
> "TEL", "ORACLE"};
> }
>
>
> _______________Perfom :
> String[] selectedAnnuaires = form.getSelectedAnnuaires();
> for (int i=0; i<selectedAnnuaires.length; i++) {
> System.out.println("\t\t"+i+" : "+selectedAnnuaires[i]); // Here i
> obtain a zero for the length of the array....
> }
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>