Note that there are some explanatory texts on larger screens.

plurals
  1. POStruts : Using Logic Iterate but not getting the updated list value in Action
    primarykey
    data
    text
    <p>I am developing a application which reads a XML , The values of these XML are set in a "Object" (consumerXML) and that object is set in a list and list will be set in session , Key being "results"</p> <pre><code>request.setAttribute("results", list) </code></pre> <p>The Flow is like this</p> <ol> <li>Welcome.JSP whose actionform is consumerxmlActionForm --> No Issues here</li> <li>editxml.jsp Even here the actionform is consumerxmlActionForm --> here list gets populated but doesnt pass the same, back.</li> </ol> <p>editxml.jsp :</p> <hr> <pre><code>&lt;%@ taglib uri="/tags/struts-bean" prefix="bean"%&gt; &lt;%@ taglib uri="/tags/struts-html" prefix="html"%&gt; &lt;%@ taglib uri="/tags/struts-logic" prefix="logic"%&gt; &lt;html:html locale="true"&gt; &lt;head&gt; &lt;title&gt;Middleware UI&lt;/title&gt; &lt;script language="JavaScript"&gt; function submitFormEdit(frm,cmd) { frm.operation.value = cmd; frm.submit(); } &lt;/script&gt; &lt;html:base /&gt; &lt;/head&gt; &lt;body bgcolor="white"&gt; &lt;html:form action="/consumerxmlActionForm"&gt; &lt;html:hidden property="operation" /&gt; &lt;html:errors /&gt; &lt;table&gt; &lt;tr&gt; &lt;td align="center"&gt;beanID&lt;/td&gt; &lt;td align="center"&gt;dayStartTime&lt;/td&gt; &lt;td align="center"&gt;dayEndTime&lt;/td&gt; &lt;td align="center"&gt;dayThreshold&lt;/td&gt; &lt;td align="center"&gt;nightThreshold&lt;/td&gt; &lt;/tr&gt; &lt;logic:iterate id="consumerXML" name="results" &gt; &lt;tr&gt; &lt;td align="center"&gt;&lt;html:text name="consumerXML" property="beanID" /&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;html:text name="consumerXML" property="dayTime" /&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;html:text name="consumerXML" property="nightTime" /&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;html:text name="consumerXML" property="dayThreshold" /&gt;&lt;/td&gt; &lt;td align="center"&gt;&lt;html:text name="consumerXML" property="nightThreshold" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/logic:iterate&gt; &lt;tr&gt; &lt;td align="right"&gt;&lt;html:submit onclick="submitFormEdit(consumerxmlActionForm, 'edit')"&gt;Change&lt;/html:submit&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/html:form&gt; &lt;/body&gt; &lt;/html:html&gt; </code></pre> <hr> <pre><code> import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import com.unicel.vo.ConsumerXML; import com.unicel.xml.ParseXML; public class ConsumerXMLAction extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String operation = request.getParameter("operation"); ConsumerXMLActionForm actionForm = (ConsumerXMLActionForm) form; if(operation != null &amp;&amp; operation.equals("edit")) { System.out.println("*** Operation is **** " + operation); System.out.println("*** actionForm.getOtherGWList() ****" + actionForm.getOtherGWList()); System.out.println("*** From Session *** " + request.getAttribute("results")); if(actionForm.getOtherGWList() != null) { for(ConsumerXML consumerXML : actionForm.getOtherGWList()) { System.out.println("*** Current XML *** " + consumerXML); } } } else { ParseXML parseXML = new ParseXML(); parseXML.parse(); actionForm.setOtherGWList(parseXML.otherGatewayConsumerList); request.setAttribute("results", parseXML.otherGatewayConsumerList); } return mapping.findForward("success"); } } import java.util.ArrayList; import org.apache.struts.action.ActionForm; import com.unicel.vo.ConsumerXML; public class ConsumerXMLActionForm extends ActionForm { private static final long serialVersionUID = 1L; private ArrayList&lt;ConsumerXML&gt; otherGWList; private String operation; private String beanID; private String dayTime; private String nightTime; private String dayThreshold; private String nightThreshold; public String getBeanID() { return beanID; } public void setBeanID(String beanID) { this.beanID = beanID; } public String getDayTime() { return dayTime; } public void setDayTime(String dayTime) { this.dayTime = dayTime; } public String getNightTime() { return nightTime; } public void setNightTime(String nightTime) { this.nightTime = nightTime; } public String getDayThreshold() { return dayThreshold; } public void setDayThreshold(String dayThreshold) { this.dayThreshold = dayThreshold; } public String getNightThreshold() { return nightThreshold; } public void setNightThreshold(String nightThreshold) { this.nightThreshold = nightThreshold; } public ArrayList&lt;ConsumerXML&gt; getOtherGWList() { return otherGWList; } public void setOtherGWList(ArrayList&lt;ConsumerXML&gt; otherGWList) { this.otherGWList = otherGWList; } public String getOperation() { return operation; } public void setOperation(String operation) { this.operation = operation; } } </code></pre> <p>editxml.jsp displays the list properly, when I click on the "change" button I dont get the "results" in session. Is there any other way to fetch that list??</p> <p>Thanks and Regards Raaghu.K </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload