Hello guys
i have a little problem, about ActionForms with Arrays variables.
these lines are part of the all class in my xclassForm
Code:
private String statePay;
private String amounttopay;
private String totalspent;
private String utility;
private PagoObra[] pagosObra = new PagoObra[3];
public void setPagosObra(int index, PagoObra pagoObra){
this.pagosObra[index]=pagoObra;
}
public PagoObra getPagosObra(int index){
return pagosObra[index];
}
public ArrayList getNumPartePagoObra(){
ArrayList list = new ArrayList();
for(int i=0;i<3;i++)
if(getPagosObra(i)!=null)
list.add(getPagosObra(i));
return list;
}
well in the Action Class to before charge a jsp page, i have these lines of code, only to see the info of each nested bean
before to load in the jsp
Code:
//fill default values
for(int i=0;i<Integer.parseInt(oif.getCantidadPartesDePago());i++){
PagoObra pagoObra = new PagoObra();
pagoObra.setNumrecibopago(null);
pagoObra.setCodObra(oif.getCodigoObra());
pagoObra.setNumpartepago(i+1+"");
pagoObra.setCantidad("0.0");
pagoObra.setFechamaxplazopago("");
oif.setPagosObra(i,pagoObra);
}
//see the values
for(int i=0;i<Integer.parseInt(oif.getCantidadPartesDePago());i++){
PagoObra pagoObra = new PagoObra();
pagoObra=oif.getPagosObra(i);
System.out.println("pagoObra.getNumrecibopago()"+pagoObra.getNumrecibopago());
System.out.println("pagoObra.getCodObra()"+pagoObra.getCodObra());
System.out.println("pagoObra.getNumpartepago()"+pagoObra.getNumpartepago());
System.out.println("pagoObra.getCantidad()"+pagoObra.getCantidad());
System.out.println("pagoObra.getFechamaxplazopago()"+pagoObra.getFechamaxplazopago());
}
so , i have (1 to 3 objects already filled in my PagoObra[])
well,first, i cant use my logic:present to ask about pagosObra[] or inclusive pagosObra[#], i must use "notEmpty"
example
Code:
<logic:notEmpty name="insertarObraForm" property="pagosObra[0]" scope="request" >
TEXTMESSAGE<br>
<html:text property="pagosObra[0].numpartepago" size="25" /><br>
<html:text property="pagosObra[0].fechamaxplazopago" maxlength="10" size="25" readonly="true"/>
<br>
<a href="#" onClick="cal.select(document.forms[0].pagosObra[0].fechamaxplazopago,'anchor1','dd/MM/yyyy'); return false;" name="anchor1" id="anchor1">Seleccionar Fecha</a>
</logic:notEmpty>
the code that u can see in my onClick is am excelent code for calendar from
http://www.mattkruse.com/javascript/calendarpopup/
well i have an array of PagoObra[],so i must use the method getNumPartePagoObra() of my classForm to can iterate with logic:iterate,
i cant do it only with PagoObra[] (inclusive here
http://struts.apache.org/1.2.9/userG...c.html#iterate)
u can read these lines
The collection to be iterated over MUST conform to one of the following requirements in order for iteration to be successful:
* An array of Java objects or primitives.
.....
i suppose that PagoObra[] is an array of Java Objects, maybe not, if i am wrong please advice me
so i have this code
Code:
<logic:present name="insertarObraForm" property="numPartePagoObra" scope="request" >
<%int i=1;%>
<logic:iterate name="insertarObraForm" property="numPartePagoObra" id="xx" scope="request" indexId="index" >
<%
String auxnumPartePagoObra = "numPartePagoObra["+index+"]";
String numpartepago = auxnumPartePagoObra+".numpartepago";
String cantidadartepago = auxnumPartePagoObra+".cantidad";
String fechamaxplazopago = auxnumPartePagoObra+".fechamaxplazopago";
String auxfecha="fechamaxpagoobra"+i;
%>
<table>
<tr>
<td>
<bean:message key="label.partespagoobra.numeropartepago" />
</td>
<td>
<html:text property="<%=numpartepago%>" size="25" readonly="true"/>
</td>
</tr>
... more fields....
<tr>
<td>
<bean:message key="label.partespagoobra.fechaplazo" />
</td>
<td>
<html:text property="<%=fechamaxplazopago%>" maxlength="10" size="25" readonly="true"/>
<br>
<a href="#" onClick="cal.select(document.forms[0].<%=fechamaxplazopago%>,'anchor1','dd/MM/yyyy'); return false;" name="anchor1" id="anchor1">Seleccionar Fecha</a>
</td>
</td>
</tr>
</table>
<br>
<% i++; %>
</logic:iterate>
so i can load the html/jsp page without any problem, here the html code created
Code:
<table>
<tr>
<td>
Parte Pago #
</td>
<td>
<input type="text" name="numPartePagoObra[0].numpartepago" size="25" value="1" readonly="readonly">
</td>
</tr>
... MORE FIELDS ...
<tr>
<td>
Fecha Maxima Pago
</td>
<td>
<input type="text" name="numPartePagoObra[0].fechamaxplazopago" maxlength="10" size="25" value="" readonly="readonly">
<br>
<a href="#" onClick="cal.select(document.forms[0].numPartePagoObra[0].fechamaxplazopago,'anchor1','dd/MM/yyyy'); return false;" name="anchor1" id="anchor1">Seleccionar Fecha</a>
</td>
</td>
</tr>
</table>
of course how a maximun of 3 times (array 0-2 )
the problem is that if i try to open of the link to see the calendarpopup, i only can see the url address with one more character '#'
no work the javascript event, i think that is coz the index [#]
if this is the reason or not, how i can resolve this?????
is threre a way to avoid getNumPartePagoObra() and use simply PagoObra[] ?????
please help
thanks so much for advanced
LIVE AT POMPEII 1972