struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <ahardy.str...@cyberspaceroad.com>
Subject Re: indexed property bug ???
Date Fri, 28 Jun 2002 16:23:32 GMT
Hi Fabrice,
I can tell you right now that the problem with putting the form bean in 
the request scope is that the form bean is created new when your user 
input request arrives, and since it's new, it doesn't have any of the 
beans to accept your data.

There's just no code in the form bean or the indexed parameters method 
to instantiate new beans. The process tries to get a bean at whatever 
index, and fails because that bean isn't there.

Arron Bates said he was working on a collection class that would 
instantiate the beans if they weren't there, so that will solve it - but 
until then, it's necessary to keep the formbean in the session.

All the best
Adam




fabrice dewasmes wrote:
> Thanks Kees for your help,
> 
> looking deeply in this archive i've found to valuable posts that explains
> that this is a known problem. I'm not isolated !! Here are the two posts for
> other users that would ask the same question :
> 
> first a post showing the same problem
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg13568.html
> second a post proposing (alleluiah !) a solution
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg31253.html
> 
> it seems that Aaron Bates from KeyboardMonkey is waiting for a reply to
> submission posting to the commons project...
> 
> I'm going to send him an email to see where all this is !
> 
> Fabrice
> 
> 
>>-----Message d'origine-----
>>De : Lips, Kees [mailto:Kees_Lips@nl.compuware.com]
>>Envoyé : vendredi 28 juin 2002 11:17
>>À : 'Struts Users Mailing List'
>>Objet : RE: indexed property bug ???
>>
>>
>>Hi Fabrice,
>>
>>I must say that I don't use a FormBean, my beans are filled by the action
>>class from a data source (data to show only) and the data is displayed by
>>the jsp. For each workflowitembean a line is created in the jsp,
>>with one or
>>more links the user may click. Each links just passes again the id of the
>>selected task and does something with it.
>>
>>It seems that your iterate tag works, no exceptions occur, but
>>that only the
>>input data gets lost?
>>Can your action class find the data, maybe put some debugging code there.
>>When the data is accessable within your action class it should also be
>>possible to get hold of it in the jsp, probably you agree.
>>Hopefully this is
>>of any help.
>>
>>here follows part of the action class code that fills the beans with data.
>>
>>	// For each task a bean is created that holds the task data
>>	// All the beans are stored as an ArrayList in the WorkFlowItemsBean
>>object.
>>    taskiterator = tasks.iterator();
>>
>>    WorkFlowItemsBean workflowitemsbean = new WorkFlowItemsBean();
>>    while (taskiterator.hasNext()) {
>>		task = (Task)taskiterator.next();
>>		WorkFlowItemBean workflowitembean = new WorkFlowItemBean();
>>		try {
>>		    workflowitembean.setName(task.getName());
>>		    workflowitembean.setId(task.getID());
>>		    workflowitembean.setState(task.getState().toString());
>>		    workflowitembean.setPriority(task.getPriority());
>>		    workflowitembean.setVar1Label(task.getVar1Label());
>>		    workflowitembean.setVar1(task.getVar1());
>>		    workflowitembean.setVar2Label(task.getVar2Label());
>>		    workflowitembean.setVar2(task.getVar2());
>>		    workflowitembean.setVar3Label(task.getVar3Label());
>>		    workflowitembean.setVar3(task.getVar3());
>>		    if (servlet.getDebug() >=1) {
>>		        servlet.log("getVar1:      " + task.getVar1());
>>		        servlet.log("getVar1Label: " + task.getVar1Label());
>>		        servlet.log("getVar2:      " + task.getVar2());
>>		        servlet.log("getVar2Label: " + task.getVar2Label());
>>		        servlet.log("getVar3:      " + task.getVar3());
>>		        servlet.log("getVar3Label: " + task.getVar3Label());
>>			}
>>
>>		}
>>		catch (WorkflowException e) {
>>			if (servlet.getDebug() >= 1)
>>			    servlet.log("WorkFlowDrivenTaskListAction,
>>WorkFlowException when creating beaninfo: "
>>			                + e.getMessage());
>>          	errors.add(ActionErrors.GLOBAL_ERROR,
>>        	           new ActionError("error.fatal.retrievetasks") );
>>        	errors.add(ActionErrors.GLOBAL_ERROR,
>>        	    	   new ActionError("error.consult") );
>>         	saveErrors(request, errors);
>>        	// show the error on the main menu
>>    	    return (new ActionForward(mapping.getInput()));
>>		}
>>		workflowitemsbean.add(workflowitembean);
>>	}
>>	// Save the reference to the workflowitemsbean in request scope.
>>	request.setAttribute(Constants.WORKFLOWDRIVEN_KEY,
>>workflowitemsbean);
>>
>>	// Forward control to the specified success URI
>>	return (mapping.findForward("success"));
>>
>>    }
>>-----Original Message-----
>>From: fabrice dewasmes [mailto:fdewasmes@kaptech.com]
>>Sent: Friday, June 28, 2002 10:52 AM
>>To: Struts Users Mailing List
>>Subject: RE: indexed property bug ???
>>
>>
>>HI,
>>
>>thanks for your help. I tried to add the scope attribute and type
>>attribute
>>but it still doesn't work. How do you get each of your workflowitemberan
>>correctly set with the user input. For example, say that your
>>workflowItemBean has a text property 'comment' that you want your user to
>>fill. The displayed html page will be sthing like :
>>N° name        status  comment
>>1. user order   OK     <input type="text">
>>1. user order   OK     <input type="text">
>>1. user order   OK     <input type="text">
>>
>>>-----Message d'origine-----
>>>De : Lips, Kees [mailto:Kees_Lips@nl.compuware.com]
>>>Envoyé : vendredi 28 juin 2002 10:25
>>>À : 'struts-user@jakarta.apache.org'
>>>Objet : RE: indexed property bug ???
>>>
>>>
>>>
>>>>Hi,
>>>>
>>>>Just to show what I use and it works for me. This working
>>>
>>>example and code
>>>
>>>>can help you to get it to work too.
>>>>In the an Action class the workflowitemsbean is filled with
>>>
>>>objects of the
>>>
>>>>kind workflowitembean. The workflowitemsbean is saved in
>>>
>>>request scope in
>>>
>>>>the action class. In this way it is available in the jsp. If
>>>
>>you want to
>>
>>>>see the action class code as well just send me an email.
>>>>Hopefully this is of any help.
>>>>
>>>>Kind regards,
>>>>Kees Lips
>>>>
>>>>jsp code used:
>>>><logic:iterate id="workflowitembean" name="workflowitemsbean"
>>>>property="tasks" scope="request"
>>>>type="com.compuware.optimal.flow.webconsole.example.WorkFlowItemBean">
>>>>
>>>>bean code:
>>>>package com.compuware.optimal.flow.webconsole.example;
>>>>
>>>>/**
>>>> * This bean holds the data of the WorkflowConnector task object.
>>>> *
>>>> * A choice is made here to not directly access the list
>>>
>>object TaskList
>>
>>>> * of the Workflow Connector. This to show that in this way you
>>>
>>>could add
>>>
>>>> * other information to these beans as well. For example you
>>>
>>>could obtain
>>>
>>>> * a specific parameter of a task and add this to the
>>>
>>>WorkFlowItemBean as
>>>
>>>>well.
>>>> * Or do a translation of the State values and store the
>>>
>>>translated value
>>>
>>>>in the
>>>> * bean.
>>>> *
>>>> * If you do not need extra information or you do not want to
>>>
>>translate
>>
>>>>values,
>>>> * the same procedure could be followed as is done for the User-Driven
>>>>Tasks. Look at
>>>> * the @see UserDrivenTaskListAction class.
>>>> *
>>>> */
>>>>
>>>>public class WorkFlowItemBean {
>>>>
>>>>   /**
>>>>    * The id of the task.
>>>>    */
>>>>   private String id;
>>>>
>>>>   /**
>>>>    * The name of the task.
>>>>    */
>>>>   private String name;
>>>>
>>>>   /**
>>>>    * The state of the task.
>>>>    */
>>>>   private String state;
>>>>
>>>>   /**
>>>>    * The priority of the task.
>>>>    */
>>>>   private String priority;
>>>>
>>>>   /**
>>>>    * The var1 property of the task. This property is used for unique
>>>>identification
>>>>    * of the task. Var1 holds the value of the process variable
>>>
>>>identified
>>>
>>>>by var1label.
>>>>    */
>>>>   private String var1;
>>>>
>>>>   /**
>>>>    * The var1label property of the task. Var1Label has the name of a
>>>>process variable that
>>>>    * was choosen to be used to identify the task.
>>>>    */
>>>>   private String var1label;
>>>>
>>>>   /**
>>>>    * The var2 property of the task. This property is used for unique
>>>>identification
>>>>    * of the task. Var2 holds the value of the process variable
>>>
>>>identified
>>>
>>>>by var2label.
>>>>    */
>>>>   private String var2;
>>>>
>>>>   /**
>>>>    * The var2label property of the task. Var2Label has the name of a
>>>>process variable that
>>>>    * was choosen to be used to identify the task.
>>>>    */
>>>>   private String var2label;
>>>>
>>>>   /**
>>>>    * The var3 property of the task. This property is used for unique
>>>>identification
>>>>    * of the task. Var3 holds the value of the process variable
>>>
>>>identified
>>>
>>>>by var3label.
>>>>    */
>>>>   private String var3;
>>>>
>>>>   /**
>>>>    * The var3label property of the task. Var3Label has the name of a
>>>>process variable that
>>>>    * was choosen to be used to identify the task.
>>>>    */
>>>>   private String var3label;
>>>>
>>>>   /**
>>>>    * The default empty constructor of this bean. All properties are
>>>>initialized here.
>>>>    */
>>>>   public WorkFlowItemBean() {
>>>>      this.id = "";
>>>>      this.name = "";
>>>>      this.state = "";
>>>>      this.priority = "";
>>>>      this.var1 = "";
>>>>      this.var1label = "";
>>>>      this.var2 = "";
>>>>      this.var2label = "";
>>>>      this.var3 = "";
>>>>      this.var3label = "";
>>>>   }
>>>>
>>>>   /**
>>>>    * Set the id of the task.
>>>>    */
>>>>   public void setId(String id) {
>>>>	   this.id = id;
>>>>   }
>>>>
>>>>   /**
>>>>    * Get the id of the task.
>>>>    */
>>>>   public String getId() {
>>>>	   return this.id;
>>>>   }
>>>>
>>>>   public void setName(String name) {
>>>>	   this.name = name;
>>>>   }
>>>>
>>>>   public String getName() {
>>>>	   return this.name;
>>>>   }
>>>>
>>>>   public void setState(String state) {
>>>>	   this.state = state;
>>>>   }
>>>>
>>>>   public String getState() {
>>>>	   return this.state;
>>>>   }
>>>>
>>>>   public void setPriority(String priority) {
>>>>	   this.priority = priority;
>>>>   }
>>>>
>>>>   public String getPriority() {
>>>>	   return this.priority;
>>>>   }
>>>>
>>>>   public void setVar1(String var1) {
>>>>	   this.var1 = var1;
>>>>   }
>>>>
>>>>   public String getVar1() {
>>>>	   return this.var1;
>>>>   }
>>>>
>>>>   public void setVar1Label(String var1label) {
>>>>	   this.var1label = var1label;
>>>>   }
>>>>
>>>>   public String getVar1Label() {
>>>>	   return this.var1label;
>>>>   }
>>>>
>>>>   public void setVar2(String var2) {
>>>>	   this.var2 = var2;
>>>>   }
>>>>
>>>>   public String getVar2() {
>>>>	   return this.var2;
>>>>   }
>>>>
>>>>   public void setVar2Label(String var2label) {
>>>>	   this.var2label = var2label;
>>>>   }
>>>>
>>>>   public String getVar2Label() {
>>>>	   return this.var2label;
>>>>   }
>>>>
>>>>   public void setVar3(String var3) {
>>>>	   this.var3 = var3;
>>>>   }
>>>>
>>>>   public String getVar3() {
>>>>	   return this.var3;
>>>>   }
>>>>
>>>>   public void setVar3Label(String var3label) {
>>>>	   this.var3label = var3label;
>>>>   }
>>>>
>>>>   public String getVar3Label() {
>>>>	   return this.var3label;
>>>>   }
>>>>
>>>>}
>>>>
>>>>
>>>>package com.compuware.optimal.flow.webconsole.example;
>>>>
>>>>import java.util.List;
>>>>import java.util.ArrayList;
>>>>
>>>>/**
>>>> * Holds WorkFlowItemBean objects. This class is maintained in request
>>>>scope and is created
>>>> * by the @see WorkFlowDrivenTaskListAction.
>>>> */
>>>>public class WorkFlowItemsBean {
>>>>
>>>>   /**
>>>>    * The list of tasks or WorkFlowItemBean objects.
>>>>    */
>>>>   private List tasks;
>>>>
>>>>   /**
>>>>    * Creates a new WorkFlowItemsBean object.
>>>>    */
>>>>   public WorkFlowItemsBean() {
>>>>      this.tasks = new ArrayList();
>>>>   }
>>>>
>>>>   /**
>>>>    * Get the List of WorkFlowItemBeans.
>>>>    */
>>>>   public List getTasks() {
>>>>	   return this.tasks;
>>>>   }
>>>>
>>>>   /**
>>>>    * Add a WorkFlowItemBean to the internal List of the
>>>
>>>WorkFlowItemsBean
>>>
>>>>object.
>>>>    */
>>>>   public void add(WorkFlowItemBean item) {
>>>>	   boolean b = this.tasks.add(item);
>>>>   }
>>>>
>>>>}
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>fabrice dewasmes [fdewasmes@kaptech.com] wrote:
>>>>
>>>>Hello, i post this again as noone seems to care...
>>>>
>>>>has anyone ever tried to use the indexed property with Struts1.1 ? My
>>>>problem is that i can't get it work when the form bean is in request
>>>>scope.
>>>>The collection that i'm getting from user input is null. Here's my jsp
>>>>code
>>>>:
>>>>
>>>><logic:iterate id="loggerList" name="loggingForm"
>>>
>>property="loggerList">
>>
>>>>  <tr>
>>>>    <td><bean:write name="loggerList" property="name"
>>>
>>>filter="true"/></td>
>>>
>>>>    <td><html:radio name="loggerList" property="level" value="DEBUG"
>>>>indexed="true"/></td>
>>>>    <td><html:radio name="loggerList" property="level" value="INFO"
>>>>indexed="true"/></td>
>>>>    <td><html:radio name="loggerList" property="level" value="WARN"
>>>>indexed="true"/></td>
>>>>    <td><html:radio name="loggerList" property="level" value="ERROR"
>>>>indexed="true"/></td>
>>>>    <td><html:radio name="loggerList" property="level" value="FATAL"
>>>>indexed="true"/></td>
>>>>  </tr>
>>>></logic:iterate>
>>>>
>>>>
>>>>and here's the form bean code :
>>>>
>>>>public void setLoggerList(java.util.ArrayList loggerList) {
>>>>  this.loggerList = loggerList;
>>>>}
>>>>public java.util.ArrayList getLoggerList() {
>>>>  return loggerList;
>>>>}
>>>>//method to get the indexed property
>>>>public LoggerBean getLoggerList(int index){
>>>>  return (LoggerBean)this.loggerList.get(index);
>>>>}
>>>>//method to set the indexed property
>>>>public void setLoggerList(int index,LoggerBean bean){
>>>>  loggerList.set(index,bean);
>>>>}
>>>>
>>>>private java.util.ArrayList loggerList;
>>>>
>>>>thanks for any help
>>>>
>>>>Fabrice
>>>>
>>>>
>>>>
>>>
>>>--
>>>The contents of this e-mail are intended for the named
>>
>>addressee only. It
>>
>>>contains information that may be confidential. Unless you are the named
>>>addressee or an authorized designee, you may not copy or use it,
>>>or disclose
>>>it to anyone else. If you received it in error please notify us
>>>immediately
>>>and then destroy it.
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:
>>><mailto:struts-user-unsubscribe@jakarta.apache.org>
>>>For additional commands, e-mail:
>>><mailto:struts-user-help@jakarta.apache.org>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><mailto:struts-user-unsubscribe@jakarta.apache.org>
>>For additional commands, e-mail:
>><mailto:struts-user-help@jakarta.apache.org>
>>
>>
>>--
>>The contents of this e-mail are intended for the named addressee only. It
>>contains information that may be confidential. Unless you are the named
>>addressee or an authorized designee, you may not copy or use it,
>>or disclose
>>it to anyone else. If you received it in error please notify us
>>immediately
>>and then destroy it.
>>
>>
>>--
>>To unsubscribe, e-mail:
> 
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>
> 
> 



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message