Re: Where are my ActionForm's changes?
I removed name and type attributes from my html:form tag. I also changed the name of the form in action-mappings but still the same problem. Is there a bug in Struts that the nested tags don't work with objects? Thanks, Marwan --- In [EMAIL PROTECTED], Sri Sankaran [EMAIL PROTECTED] wrote: Get rid of the 'name' and 'type' attributes from the html:form. The reasons? * they are deprecated. See http://jakarta.apache.org/struts/userGuide/struts-html.html#form * they are not necessary * in your case the action mapping is referring to the form-bean by the name 'myForm' and the html:form's 'name' attribute is indicating that a form named 'updateOrderForm' be used. These will result in two instances of the same class. Not what you want Hope that helps Sri -Original Message- From: MarwanSalam [EMAIL PROTECTED] [mailto:marwansalam@y...] Sent: Thursday, February 20, 2003 3:58 PM To: [EMAIL PROTECTED] Subject: Re: Where are my ActionForm's changes? Hi Sri, You got it right. This is the code from my Action class that checks for the changes and forwards the request to the same page again(I tried to forward to a view-only page(showorderdetails.jsp) for testing purposes and the changes still were not reflected). UpdateOrdersAction.java - UpdateOrderForm updateOrderForm = (UpdateOrderForm) form; if (updateOrder.equalsIgnoreCase(action)) { List parametersList = updateOrderForm.getParameterList(); int size = parametersList.size(); for (int i = 0; i size; i++) { OrderDetailModel model = ((UpdateOrderForm) form).getOrderDetail (i); logger.debug(Form model is: + model); } Iterator iter = parametersList.iterator(); if (logger.isDebugEnabled()) { while (iter.hasNext()) { OrderDetailModel orderDetail = (OrderDetailModel)iter.next(); logger.debug(orderDetail.toString()); } } logger.debug( Forwarding to 'edit' page); NDC.pop(); return (mapping.findForward(edit)); // this will take you back to the same page } Here is an excerpt from updateorder.jsp: - html:form action=updateOrder name=updateOrderForm type=mypackage.UpdateOrderForm scope=session html:hidden property=action value=updateOrder / logic:iterate id=parameter name=updateOrderForm property=parameterList tr tdbean:write name=parameter property=orderLineNumber //td tdbean:write name=parameter property=itemName //td tdbean:write name=parameter property=quantityOrdered //td tdhtml:text name=parameter property=quantityCancelled indexed=true size=3 maxlength=3//td tdhtml:text name=parameter property=status indexed=true size=3 maxlength=3//td /tr /logic:iterate html:submit/ /html:form I appreciate your help. Marwan --- In [EMAIL PROTECTED], Sri Sankaran [EMAIL PROTECTED] wrote: What I have gleaned so far, is * the user is viewing JSP-1 * the user updates the data and submits (invoking the action mapping you have shown (path=/updateOrder) Questions: * Are you detecting the updated data value(s) in your action? * Where is the user being directed? If showorderdetails.jsp or updateorder.jsp what is mapping for those pages? * Where are you noticing problems? Remember that if you go to new page and it uses a form-bean of the same class but referred to by a different name, a new instance will be used. Sri -Original Message- From: MarwanSalam [EMAIL PROTECTED] [mailto:marwansalam@y...] Sent: Thursday, February 20, 2003 1:55 PM To: [EMAIL PROTECTED] Subject: Re: Where are my ActionForm's changes? Thanks Sri for the quick reply. The first of two assumptions you mentioned below are not true but I am not sure about the third one: forwarding to an action that is re- initializing the form. My ActionForm.reset() is as follows: public void reset(ActionMapping mapping, HttpServletRequest request) { action = null; } And here is my action-mapping: action path=/updateOrder type=MyAction name=myForm scope=session validate=false input=/updateorder.jsp forward name=update path=/showorderdetails.jsp/ forward name=edit path=/updateorder.jsp/ /action The reset method does not have any code that initializes the form parameters so I don't know why this is happening. Marwan --- In [EMAIL PROTECTED], Sri Sankaran [EMAIL PROTECTED] wrote: I'm not sure I understand completely. Are you returning to the same page after the form is submitted? What are you doing in the reset() and Action? That notwithstanding, here are some possibilities: * The text fields are not within a form * You are re-directing to the page and not forwarding * You are forwarding (or redirecting) to an action that is re-initializing the form
Where are my ActionForm's changes?
Hi, I am using the login:iterate tag to display a collection of objects. The objects have attributes that some can be edited by the user. After the user changes some values and submits back to the Action class, the values that were changed in the JSP are not reflected in the form. I know that because I tried to iterate through the collection and displayed the values retained from both the ActionForm.reset() and from the Action class. No changes are retained; only the original values. I am using Struts 1.1-b3. Here is my ActionForm: private List parameterList = new ArrayList(); public List getParameterList() { return parameterList; } public void setParameterList(List parameterList) { this.parameterList = parameterList; } public MyObject getMyObject(int index) { return (MyObject) parameterList.get(index); } What's wrong? Marwan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Where are my ActionForm's changes?
Thanks Sri for the quick reply. The first of two assumptions you mentioned below are not true but I am not sure about the third one: forwarding to an action that is re- initializing the form. My ActionForm.reset() is as follows: public void reset(ActionMapping mapping, HttpServletRequest request) { action = null; } And here is my action-mapping: action path=/updateOrder type=MyAction name=myForm scope=session validate=false input=/updateorder.jsp forward name=update path=/showorderdetails.jsp/ forward name=edit path=/updateorder.jsp/ /action The reset method does not have any code that initializes the form parameters so I don't know why this is happening. Marwan --- In [EMAIL PROTECTED], Sri Sankaran [EMAIL PROTECTED] wrote: I'm not sure I understand completely. Are you returning to the same page after the form is submitted? What are you doing in the reset() and Action? That notwithstanding, here are some possibilities: * The text fields are not within a form * You are re-directing to the page and not forwarding * You are forwarding (or redirecting) to an action that is re-initializing the form. Will need to see the necessary action mappings too. Sri -Original Message- From: MarwanSalam [EMAIL PROTECTED] [mailto:marwansalam@y...] Sent: Thursday, February 20, 2003 1:09 PM To: [EMAIL PROTECTED] Subject: Where are my ActionForm's changes? Hi, I am using the login:iterate tag to display a collection of objects. The objects have attributes that some can be edited by the user. After the user changes some values and submits back to the Action class, the values that were changed in the JSP are not reflected in the form. I know that because I tried to iterate through the collection and displayed the values retained from both the ActionForm.reset() and from the Action class. No changes are retained; only the original values. I am using Struts 1.1-b3. Here is my ActionForm: private List parameterList = new ArrayList(); public List getParameterList() { return parameterList; } public void setParameterList(List parameterList) { this.parameterList = parameterList; } public MyObject getMyObject(int index) { return (MyObject) parameterList.get(index); } What's wrong? Marwan -- --- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Where are my ActionForm's changes?
Hi Sri, You got it right. This is the code from my Action class that checks for the changes and forwards the request to the same page again(I tried to forward to a view-only page(showorderdetails.jsp) for testing purposes and the changes still were not reflected). UpdateOrdersAction.java - UpdateOrderForm updateOrderForm = (UpdateOrderForm) form; if (updateOrder.equalsIgnoreCase(action)) { List parametersList = updateOrderForm.getParameterList(); int size = parametersList.size(); for (int i = 0; i size; i++) { OrderDetailModel model = ((UpdateOrderForm) form).getOrderDetail(i); logger.debug(Form model is: + model); } Iterator iter = parametersList.iterator(); if (logger.isDebugEnabled()) { while (iter.hasNext()) { OrderDetailModel orderDetail = (OrderDetailModel)iter.next(); logger.debug(orderDetail.toString()); } } logger.debug( Forwarding to 'edit' page); NDC.pop(); return (mapping.findForward(edit)); // this will take you back to the same page } Here is an excerpt from updateorder.jsp: - html:form action=updateOrder name=updateOrderForm type=mypackage.UpdateOrderForm scope=session html:hidden property=action value=updateOrder / logic:iterate id=parameter name=updateOrderForm property=parameterList tr tdbean:write name=parameter property=orderLineNumber //td tdbean:write name=parameter property=itemName //td tdbean:write name=parameter property=quantityOrdered //td tdhtml:text name=parameter property=quantityCancelled indexed=true size=3 maxlength=3//td tdhtml:text name=parameter property=status indexed=true size=3 maxlength=3//td /tr /logic:iterate html:submit/ /html:form I appreciate your help. Marwan --- In [EMAIL PROTECTED], Sri Sankaran [EMAIL PROTECTED] wrote: What I have gleaned so far, is * the user is viewing JSP-1 * the user updates the data and submits (invoking the action mapping you have shown (path=/updateOrder) Questions: * Are you detecting the updated data value(s) in your action? * Where is the user being directed? If showorderdetails.jsp or updateorder.jsp what is mapping for those pages? * Where are you noticing problems? Remember that if you go to new page and it uses a form-bean of the same class but referred to by a different name, a new instance will be used. Sri -Original Message- From: MarwanSalam [EMAIL PROTECTED] [mailto:marwansalam@y...] Sent: Thursday, February 20, 2003 1:55 PM To: [EMAIL PROTECTED] Subject: Re: Where are my ActionForm's changes? Thanks Sri for the quick reply. The first of two assumptions you mentioned below are not true but I am not sure about the third one: forwarding to an action that is re- initializing the form. My ActionForm.reset() is as follows: public void reset(ActionMapping mapping, HttpServletRequest request) { action = null; } And here is my action-mapping: action path=/updateOrder type=MyAction name=myForm scope=session validate=false input=/updateorder.jsp forward name=update path=/showorderdetails.jsp/ forward name=edit path=/updateorder.jsp/ /action The reset method does not have any code that initializes the form parameters so I don't know why this is happening. Marwan --- In [EMAIL PROTECTED], Sri Sankaran [EMAIL PROTECTED] wrote: I'm not sure I understand completely. Are you returning to the same page after the form is submitted? What are you doing in the reset() and Action? That notwithstanding, here are some possibilities: * The text fields are not within a form * You are re-directing to the page and not forwarding * You are forwarding (or redirecting) to an action that is re-initializing the form. Will need to see the necessary action mappings too. Sri -Original Message- From: MarwanSalam [EMAIL PROTECTED] [mailto:marwansalam@y...] Sent: Thursday, February 20, 2003 1:09 PM To: [EMAIL PROTECTED] Subject: Where are my ActionForm's changes? Hi, I am using the login:iterate tag to display a collection of objects. The objects have attributes that some can be edited by the user. After the user changes some values and submits back to the Action class, the values that were changed in the JSP are not reflected in the form. I know that because I tried to iterate through the collection and displayed the values retained from both the ActionForm.reset() and from the Action class. No changes are retained; only the original values. I am using Struts 1.1-b3. Here is my ActionForm: private List parameterList = new ArrayList(); public List getParameterList() { return parameterList; } public void setParameterList(List parameterList) { this.parameterList = parameterList; } public MyObject getMyObject(int index
Could not find Java 1.4 encode method
Hi, I upgraded from Struts v1.02 to v1.1-b3 and now I am getting the below error stack. Doesn't 1.1-b3 run on JRE 1.3.1? Marwan 2003-02-19 13:49:00,383 [8585544 DEBUG Servlet.Engine.Transports:9 - util.RequestUtils(1869)] - Could not find Java 1.4 encode method. Using deprecated version. java.lang.NoSuchMethodException: encode at java.lang.Class.getMethod0(Native Method) at java.lang.Class.getMethod(Class.java:928) at org.apache.struts.util.RequestUtils.encodeURL (RequestUtils.java:1859) at org.apache.struts.util.RequestUtils.computeURL (RequestUtils.java:514) at org.apache.struts.taglib.html.LinkTag.calculateURL (LinkTag.java:495) at org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:353) at _showcategories_jsp_57._jspService(_showcategories_jsp_57.java:278) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:142) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service (JspServlet.java:312) at org.apache.jasper.runtime.JspServlet.serviceJspFile (JspServlet.java:487) at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:620) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.ibm.servlet.engine.webapp.StrictServletInstance.doService (ServletManager.java:827) at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service (StrictLifecycleServlet.java:167) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Attribute indexed invalid according to the specified TLD
Hi, I am getting Attribute indexed invalid according to the specified TLD in my JSP. Here is part of my ActionForm: private List parameterList = new ArrayList(); public List getParameterList() { logger.debug(List size is: + this.parameterList.size()); return parameterList; } public void setParameterList(List parameterList) { this.parameterList = parameterList; } public OrderDetailModel getOrderDetail(int index) { return (OrderDetailModel) parameterList.get(index); } Here is the code in my Action where I set the form on the session: updateOrderForm.setParameterList(orderDetailList); //orderDetailList is my ArrayList object session.setAttribute(updateOrderForm, updateOrderForm); Here is my JSP: html:form action=updateOrder.do name=updateOrderForm type=com.academy.ordering.forms.UpdateOrderForm logic:iterate id=parameter name=updateOrderForm property=parameterList tr bgcolor=%= bgColor % tdhtml:text name=parameter property=orderLineNumber indexed=true //td tdhtml:text name=parameter property=itemName indexed=true //td tdhtml:text name=parameter property=quantityOrdered indexed=true //td /tr /logic:iterate input type=submit valueUpdate /html:form I looked at the Struts html:text tag description, http://jakarta.apache.org/struts/struts-html.html#text, and it says that I can use indexed. I am using Struts 1.0.2. I am doing something wrong? Thanks, Marwan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Error 500: Cannot retrieve definition for form bean null
Hi, I am getting Error 500: Cannot retrieve definition for form bean null when I use the form tag html:form action=/updateOrder.do. However, if I use form action=updateOrder.do method=post, I don't get that error. Is there something wrong I am doing? Here is the action-mapping from struts-config: actionpath=/updateOrder type=mypackage.UpdateOrdersAction name=updateOrderForm scope=session validate=false input=/updateorder.jsp forward name=update path=/showorderdetails.jsp/ forward name=edit path=/updateorder.jsp/ /action Here is my form-bean definition from struts-config: form-bean name=updateOrderForm type=mypackage.UpdateOrderForm/ Thanks, Marwan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: posting an updated collection back to Action
Hi, I looked at all your the responses to this thread and then looked at Ted Husted's Struts Tip #6 - Use an array to capture multiple parameters to solve my problem. However, I still have some problems when I submit my changes(even if I don't change anything). My ActionForm looks like this: private String[] orderLineNumber = null; private String[] quantityShipped = null; private String[] quantityCancelled = null; with setters and getters for these attributes. In the ActionForm constructor there is nothing to initialize the arrays. After submitting the form, I am trying to access these arrays in the Action class like this: String[] lineNumber = (UpdateForm)form.getOrderLineNumber(); and I get a java.lang.NullPointerException on this exact line. My JSP looks like this: %List orderDetailList=(List)session.getAttribute(Constants.ORDERS);% code form action=updateOrder.do method=post logic:iterate id=orderDetail name=orderDetailList tdbean:write name=orderDetail property=orderLineNumber/td tdhtml:text name=orderDetail property=quantityShipped //td tdhtml:text name=orderDetailproperty=quantityCancelled//td /logic:iterate input type=submit valueUpdate /form /code This is still not working. The lines in the JSP are objects and not Strings. My JSP is retrieving a collection of these objects to display in a grid as you see above. Can I have these objects in my ActionForm instead of defining arrays for each column in the JSP? All I need to do is retrieve the grid of data from the JSP to my Action class with one submit button. That's all. Thanks, Marwan --- In [EMAIL PROTECTED], John Espey [EMAIL PROTECTED] wrote: You can create indexed properties ( getOrderDetail(int), setOrderDetail(int, string) ) You have to back them whatever way you see fit (I've used arrays in the past but I had to make sure they were sized propertly on each call). On your JSP, the resulting names for your input fields will need to be indexed: html:text name=orderDetail property=quantityShipped [${index}]/ will work if you are using the EL version of the html taglib. (Although I'm not sure the name property has to be specified if you use the html:form tag instead of the form tag as you've shown here) -Original Message- From: MarwanSalam [EMAIL PROTECTED] [mailto:marwansalam@y...] Sent: Monday, February 10, 2003 5:46 PM To: [EMAIL PROTECTED] Subject: posting an updated collection back to Action Hi, I have a list of line items displayed in a JSP where some of the attributes can be edited. I would like to capture the updated data by the user to return it to my Action class so I can modify my model accordingly. Here is my JSP code: form action=updateOrder.do method=post input type=hidden name=action value=updateOrder logic:iterate id=orderDetail type=OrderDetailModel collection=%= orderDetailList % tdhtml:text name=orderDetail property=quantityShipped//td /logic:iterate input type=submit valueUpdate Order /form I know my ActionForm class has to have a property called orderDetailList. But the question is, how will the correct index be updated since my list can contain many OrderDetailModel's? Should I add a method in my ActionForm class like getOrderDetailList.get (index)? Help!!! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
posting an updated collection back to Action
Hi, I have a list of line items displayed in a JSP where some of the attributes can be edited. I would like to capture the updated data by the user to return it to my Action class so I can modify my model accordingly. Here is my JSP code: form action=updateOrder.do method=post input type=hidden name=action value=updateOrder logic:iterate id=orderDetail type=OrderDetailModel collection=%= orderDetailList % tdhtml:text name=orderDetail property=quantityShipped//td /logic:iterate input type=submit valueUpdate Order /form I know my ActionForm class has to have a property called orderDetailList. But the question is, how will the correct index be updated since my list can contain many OrderDetailModel's? Should I add a method in my ActionForm class like getOrderDetailList.get (index)? Help!!! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
j_security_check with LogonAction
Hi, I am trying to use j_security_check Servlet to authenticate users from a login.jsp. However, if I do this, I will not be able to take advantage of LogonAction class where I need to set certain session and request attributes. If I submit the logon form to LogonAction, I can forward the request from LogonAction to j_security_check but the request object will stay there and I can not forward again using mapping.findForward(success) to a different page since the response is already commited at that point. Is there a way to work around this? Marwan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Cannot find bean categoryArray in scope request
Hi, I am using Struts where I have an ShowCategoriesAction that extends Action. In the perform method, I am reading data from the database and storing it in a collecion object(ArrayList). Then I am using request.setAttribute(categoryArray, myCollectionObject) to set it on the request. I have verified that the collection has actual data before forwarding to the JSP. Now, when I call mapping.findForward(success) from the perform method, it forwards the request to a showCategories.jsp page where I use the following Struts tag: code logic:iterate id=category type=myPackage.Category name=categoryArray scope=request html:link page=/showItems.do name=category property=mapping bean:write name=category property=categoryName filter=true/ /html:link /logic:iterate /code I get this error: boldcodeError 500: Cannot find bean categoryArray in scope request /code/bold I even tried to put the object on the session and the application and look it up in the iterate tag and still the same problem. I tried to print the attributes on the request object from the JSP and it did show the categoryArray object there. But apparantly it was null. Can anyone help me in figuring out what the problem is. I am using WebSphere 4.0.3 for the Servlet container. Thanks, Marwan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]