Hi to all. I have a problem with a logic:iterate tag. I'm using Struts 1.3. I have to populate a select with data read from db (by invoking the first Action). When a select option is selected in the jsp, I have to invoke a second Action (on the same jsp page) which has to perform some operations and remember the previous selected option (in the select). I show you my source code for semplicity.
Here is my ActionForm. ******************************* CreazioneProfiloUtenteForm.java ******************************* public class CreazioneProfiloUtenteForm extends ActionForm { private String sport; public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) { return null; } public void reset(ActionMapping mapping, HttpServletRequest request) { } public String getSport() { return sport; } public void setSport(String sport) { this.sport = sport; } } First, the ToCreazioneProfiloUtenteAction action is invoked. This action reads data from db and insert them in the ArrayList 'listaSport'; at the end, this ArrayList is setted in the request. *********************************** ToCreazioneProfiloUtenteAction.java *********************************** public class ToCreazioneProfiloUtenteAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) { ... ... ArrayList listaSport = null; listaSport = new ArrayList(); listaSport.add(new org.apache.struts.util.LabelValueBean(defaultOptionSelect,"")); while(db.getResultSet().next()) listaSport.add(new org.apache.struts.util.LabelValueBean(db.getResultSet().getString("nomeSport"),db.getResultSet().getString("idSport"))); request.setAttribute("listaSport", listaSport); ... ... } } Then creazioneProfiloUtente.jsp is invoked. I have a select 'sport' that reads the collections in the ArrayList 'listaSport'. Then, I have to store in hidden fields the values of the 'listaSport' arraylist in order to avoid, in the second Action, to re-access to db to read the same values. In order to do so, I use logic:iterate but I have problems with it. I confirm that if I delete from source code the tag logic:iterate, all works well. ************************** creazioneProfiloUtente.jsp ************************** ... ... <html:select property="sport" styleId="sport" o_nchange="javascript:submitForm('creazioneProfiloUtenteForm','caricamentoRuoliAttributiSport.do')"> <html:optionsCollection name="listaSport" /> </html:select> <logic:iterate id="sport" name="listaSport"> <html:hidden name="sport" property="label" indexed="true" /> <html:hidden name="sport" property="value" indexed="true" /> </logic:iterate> ... ... This is the second Action, which should be invoked when a select option is selected by user. Unfortunately, this Action is never accessed because I got a java NullPointerException before. ***************************************** CaricamentoRuoliAttributiSportAction.java ***************************************** public class CaricamentoRuoliAttributiSportAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) { System.out.println("XXXXXXXXXXXXXXXXX"); } } ********* EXCEPTION ********* GRAVE: Servlet.service() for servlet action threw exception java.lang.NullPointerException at org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:427) at org.apache.commons.beanutils.PropertyUtilsBean.getIndexedProperty(PropertyUtilsBean.java:340) at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:684) at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715) at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:884) at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811) at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298) at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:467) at org.apache.struts.chain.commands.servlet.PopulateActionForm.populate(PopulateActionForm.java:50) at org.apache.struts.chain.commands.AbstractPopulateActionForm.execute(AbstractPopulateActionForm.java:60) at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304) at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190) at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:856) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:565) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509) at java.lang.Thread.run(Unknown Source) ***************** STRUTS-CONFIG.XML ***************** ... ... <struts-config> <form-beans > <form-bean name="creazioneProfiloUtenteForm" type="it.sfidiamoci.struts.form.CreazioneProfiloUtenteForm" /> </form-beans> ... ... <action-mappings > <action attribute="creazioneProfiloUtenteForm" name="creazioneProfiloUtenteForm" path="/toCreazioneProfiloUtente" scope="request" type="it.sfidiamoci.struts.action.ToCreazioneProfiloUtenteAction" > <forward name="toCreazioneProfiloUtenteOk" path="/creazioneProfiloUtente.jsp" /> <forward name="toCreazioneProfiloUtenteErrore" path="/creazioneProfiloUtente.jsp" /> </action> <action attribute="creazioneProfiloUtenteForm" input="/creazioneProfiloUtente.jsp" name="creazioneProfiloUtenteForm" path="/caricamentoRuoliAttributiSport" scope="request" type="it.sfidiamoci.struts.action.CaricamentoRuoliAttributiSportAction"> <forward name="caricamentoRuoliAttributiSportOk" path="/creazioneProfiloUtente.jsp" /> <forward name="caricamentoRuoliAttributiSportErrore" path="/creazioneProfiloUtente.jsp" /> </action> </action-mappings> ... ... I can't understand where is the problem. Can you help me? Thanks to all in advance. Bye bye. -- View this message in context: http://www.nabble.com/logic%3Aiterate-problem%3A-NullPointerException-tp19349501p19349501.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]