Java Mailing List Archive

http://www.gg3721.com/

Home » Struts Users Mailing List »

Problems with Indexed Properties, Hidden Values and Logic Iterate
Tag

cacodemon79

2008-09-21

Replies: Find Java Web Hosting

Author LoginPost Reply

Hi to all.
I'm using Struts 1.3, Tomcat 6.0 and Eclipse.

I have a problem with Indexed Properties.
I have a jsp that should save hidden values and pass it to the linked
Action.

I show you my code.

********
JSP PAGE
********

<logic:notEmpty name="creazioneProfiloUtenteForm" property="listaSport">
               <html:select property="sport" styleId="sport"
o_n_c_h_a_n_g_e="javascript:submitForm('creazioneProfiloUtenteForm','caricamentoRuoliAttributiSport.do')">
                 <html:optionsCollection property="listaSport" />
               </html:select>
               
               <logic:iterate id="hSportBean" name="creazioneProfiloUtenteForm"
property="listaSport">
                 <html:hidden name="hSportBean" property="label" indexed="true" />
                 <html:hidden name="hSportBean" property="value" indexed="true" />
               </logic:iterate>
             </logic:notEmpty>

where
- 'listaSport' is a list containing a list of sports. This list is correctly
populated by the previous Action through 'select' and 'optionsCollection'
tags.
- 'hSportBean' is a LabelValueBean list where I have to save the select
options.

***********
ACTION FORM
***********

public class CreazioneProfiloUtenteForm extends ActionForm
{
 private String sport;
 private ArrayList listaSport;
 private ArrayList listaRuoli;
 private Object[] ruoliSelezionati;
 
 public ActionErrors validate(ActionMapping mapping,HttpServletRequest
request) {
   return null;
 }
 
 public void reset(ActionMapping mapping, HttpServletRequest request) {
   
 }
 
 public LabelValueBean getHSportBean(int index)
  {
    if(this.listaSport == null)
    {
       this.listaSport = new ArrayList();
    }
   
    while(index >= this.listaSport.size())
    {
       this.listaSport.add(new LabelValueBean());
    }

    return (LabelValueBean) listaSport.get(index);
  }

 public String getSport() {
   return sport;
 }

 public void setSport(String sport) {
   this.sport = sport;
 }

 public ArrayList getListaSport() {
   return listaSport;
 }

 public void setListaSport(ArrayList listaSport) {
   this.listaSport = listaSport;
 }

 public ArrayList getListaRuoli() {
   return listaRuoli;
 }

 public void setListaRuoli(ArrayList listaRuoli) {
   this.listaRuoli = listaRuoli;
 }

 public Object[] getRuoliSelezionati() {
   return ruoliSelezionati;
 }

 public void setRuoliSelezionati(Object[] ruoliSelezionati) {
   this.ruoliSelezionati = ruoliSelezionati;
 }

}


******
ACTION
******

public class CaricamentoRuoliAttributiSportAction extends Action
{  
 public ActionForward execute(ActionMapping mapping, ActionForm
form,HttpServletRequest request, HttpServletResponse response)
 {
   CreazioneProfiloUtenteForm creazioneProfiloUtenteForm =
(CreazioneProfiloUtenteForm) form;// TODO Auto-generated method stub
     sportSelezionato = creazioneProfiloUtenteForm.getSport();

//HERE I HAVE TO LOAD HIDDEN VALUES SAVED IN JSP PAGE

...
...

 }
}


The problem is that I can't load in Action the hidden values saved in the
jsp page.
I tried to print the values received

System.out.println((creazioneProfiloUtenteForm.getHSportBean(0)).getLabel())
System.out.println((creazioneProfiloUtenteForm.getHSportBean(0)).getValue());
but I always obtain null values (for all indexes).

So, I don't know how to solve my problem.

I also followed guidelines in:
http://faq.javaranch.com/java/IndexedProperties
http://faq.javaranch.com/java/IndexedProperties
http://struts.apache.org/1.x/struts-taglib/indexedprops.html
http://struts.apache.org/1.x/struts-taglib/indexedprops.html
http://mail-archives.apache.org/mod_mbox/struts-user/200604.mbox/%3C5B7D2ACE8204B748980CEB2DBFAB90B3972E53@(protected)
http://mail-archives.apache.org/mod_mbox/struts-user/200604.mbox/%3C5B7D2ACE8204B748980CEB2DBFAB90B3972E53@(protected)

Can you help me?

Thanks a lot in advance.
--
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 gg3721.com - Jax Systems, LLC, U.S.A.