Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Struts
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Struts section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 22nd, 2006, 09:08 PM
Authorized User
 
Join Date: Apr 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Nested Beans and JavaScript Problem

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
__________________
LIVE AT POMPEII 1972





Similar Threads
Thread Thread Starter Forum Replies Last Post
Deployment Problem (JSP + Java Beans)!!!! sagar.singh JSP Basics 3 December 7th, 2007 02:03 AM
Problem nested elements Geierwally XSLT 7 May 9th, 2007 07:27 AM
Problem with nested transaction balesh ASP.NET 1.0 and 1.1 Professional 1 November 25th, 2006 01:38 PM
Using Javascript in Nested Datalist savan_thakkar ASP.NET 1.0 and 1.1 Professional 0 March 21st, 2006 05:54 PM
Nested DataList Problem orcities C# 0 July 12th, 2004 01:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.