You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by shanmugampl <sh...@adventnet.com> on 2004/03/09 09:47:27 UTC

Re: Populating form Elements from another object.

Hi,

    I saw your code. I have one doubt. How do you plugin your own 
DynaBean implementation into the struts framework.

Shanmugam PL

Niall Pemberton wrote:

>I wrote these....
>
>http://www.niallp.pwp.blueyonder.co.uk
>
>Niall
>
>----- Original Message ----- 
>From: "shanmugampl" <sh...@adventnet.com>
>To: <st...@jakarta.apache.org>
>Sent: Wednesday, February 25, 2004 7:00 AM
>Subject: Populating form Elements from another object.
>
>
>  
>
>>Hi,
>>
>>      I have a requirement where i need to populate the values of a form 
>>from another object, and then again transform the contents of the form 
>>back to the object once the form is submitted. i.e Say, when i click a 
>>button, i do some functionalities and have a Properties object as an 
>>output. The keys in the Properties object are not static. These values 
>>need to be shown in a form. As the keys retrieved for the current 
>>operation is not known, i cant define the values in the 
>>struts-config.xml for the dynaactionclass.
>>
>>       Is it possible to extend the dynaactionclass, and during its init 
>>or something, iterate the properties object and populate the form.  Are 
>>there any other way of doing it.
>>
>>Thanks
>>Shanmugam PL
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>

Re: Populating form Elements from another object.

Posted by shanmugampl <sh...@adventnet.com>.
Hi Niall,

       I figured out the problem. The problem was that, my DynaClass 
returned the class name for the getName() method call , whereas the 
DynaActionFormClass returns the name through getName() method of 
FormBeanConfig. This is the key that is used to store and retrieve the 
bean instance. As a result, in the createActionForm of RequestUtils, the 
if check(in bold ) will fail and the stored instance will not be returned.

            if (config.getDynamic()) {
                String className = ((DynaBean) 
instance).getDynaClass().getName();
             *   if (className.equals(config.getName())) {*
                    if (log.isDebugEnabled()) {
                        log.debug(
                            " Recycling existing DynaActionForm instance "
                                + "of type '"
                                + className
                                + "'");
                        log.trace(" --> " + instance);
                    }
                    return (instance);
                }

As my class is an extension of DynaActionForm, the following if check 
will be satisfied, and a new instance will be returned each and every time.

       if (config.getDynamic()) {
            try {
*                DynaActionFormClass dynaClass =
                    DynaActionFormClass.createDynaActionFormClass(config);
                instance = (ActionForm) dynaClass.newInstance();*
                ((DynaActionForm) instance).initialize(mapping);
                if (log.isDebugEnabled()) {
                    log.debug(
                        " Creating new DynaActionForm instance "
                            + "of type '"
                            + config.getType()
                            + "'");
                    log.trace(" --> " + instance);
                }
            }


 I have rectified it by  writing a separate implementation instead of 
extending the DynaActionForm, so that the else part of the first code 
snippet will be executed. Now everything is working fine. Thanks for 
your contribution without which i would be duplicating the informations 
in the jsp page and the xml file.  Your idea has reduced a lot of 
coding. Thanks once again

Thanks
Shanmugam PL


Niall Pemberton wrote:

>Shanmugam,
>
>I think your problem lies in the way you have defined your two actions in the struts-config.xml - one of them has scope="session" and the other doesn't, which means it will probably default to request. I think this is causing your problem because Struts only looks for the ActionForm in the scope of the mapping specified - so in your case I believe its creating two versions of "severityForm". Try addding a scope="session" to your "/severityDetails" action and see if that sorts it out.
>
>Niall
>
>  ----- Original Message ----- 
>  From: shanmugampl 
>  To: Struts Users Mailing List 
>  Sent: Friday, March 12, 2004 3:55 AM
>  Subject: Re: Populating form Elements from another object.
>
>
>  Hi Niall,
>
>         Thanks for your inputs. I followed your methodology with slight changes. I have a class MCDynaClass which equals your LazyDynaClass. Instead of having a separate bean as LazyDynaBean, i extended the DynaActionForm as MCDynaActionForm and overridden the set methods as per my requirement.  The entry in the struts-config.xml will be like 
>
>  <form-beans>
>      <form-bean name = "severityForm" type = "com.adventnet.client.struts.action.MCDynaActionForm"/>
>  </form-beans>
>
>  <action path = "/severityDetails" type = "com.adventnet.client.struts.action.SeverityDetailsAction"   name = "severityForm" >
>     <forward name = "details" path = "/jsp/detailsPage.jsp"/>
>  </action>
>  <action path = "/updateSeverity" type = "com.adventnet.client.struts.action.UpdateSeverityDetailsAction" name = "severityForm" input = "/severityDetails.do" scope = "session">
>        <forward name = "success" path = "/jsp/results.jsp"/>
>  </action>
>
>         In the  ActionClass i will get the DataObject(my own object) and set it to the form through the setDataObject method.
>
>  MCDynaActionForm userForm = (MCDynaActionForm) form;
>  userForm.setDataObject(newDO);
>
>         By this way i am able to populate the values dynamically. The problems comes when i am submitting the form. When the form is submitted, the instance of the form that i am getting in the action class is different. As a result, I cannot update the dataObject as it is null. I could not figure out where i have gone wrong. I have attached my source. Kindly help me.
>
>  Thanks
>  Shanmugam PL
>
>
>
>  Niall Pemberton wrote:
>
>Yup, thats it - plus dynamic="true"
>
> <form-bean name="fooForm1"
>type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
> <form-bean name="fooForm2"
>type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
> <form-bean name="fooForm3"
>type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
> <form-bean name="fooForm4"
>type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
>
>Oh, I noticed an error in LazyValidatorForm, its declared as "abstract" -
>which it shouldn't be - I don't use it directly, I use
>LazyValidatorActionForm which extends it.
>
>Niall
>
>
>----- Original Message ----- 
>From: "Mark Lowe" <ma...@talk21.com>
>To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>Sent: Tuesday, March 09, 2004 8:53 AM
>Subject: Re: Populating form Elements from another object.
>
>
>  I haven't seen the code but if what i understand of what Niall has been
>saying you'd  use them instead of DynaActionForm.
>
><form-bean name="fooForm" type="com.ilovesparrows.struts.NiallsForm" />
>
>of course you'll need to call the package and class name to something
>appropriate.
>
>On 9 Mar 2004, at 09:47, shanmugampl wrote:
>
>    Hi,
>
>   I saw your code. I have one doubt. How do you plugin your own
>DynaBean implementation into the struts framework.
>
>Shanmugam PL
>
>Niall Pemberton wrote:
>
>      I wrote these....
>
>http://www.niallp.pwp.blueyonder.co.uk
>
>Niall
>
>----- Original Message ----- From: "shanmugampl"
><sh...@adventnet.com>
>To: <st...@jakarta.apache.org>
>Sent: Wednesday, February 25, 2004 7:00 AM
>Subject: Populating form Elements from another object.
>
>
>
>        Hi,
>
>     I have a requirement where i need to populate the values of a
>form from another object, and then again transform the contents of
>the form back to the object once the form is submitted. i.e Say,
>when i click a button, i do some functionalities and have a
>Properties object as an output. The keys in the Properties object
>are not static. These values need to be shown in a form. As the keys
>retrieved for the current operation is not known, i cant define the
>values in the struts-config.xml for the dynaactionclass.
>
>      Is it possible to extend the dynaactionclass, and during its
>init or something, iterate the properties object and populate the
>form.  Are there any other way of doing it.
>
>Thanks
>Shanmugam PL
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>          ---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>        ---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>    
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>
>------------------------------------------------------------------------------
>
>
>  package com.adventnet.client.struts.action;
>
>  import org.apache.struts.action.DynaActionForm;
>
>  import java.lang.reflect.Array;
>  import java.util.*;
>  import com.adventnet.persistence.ejb.*;
>  import com.adventnet.persistence.*;
>  import com.adventnet.nms.ms.config.client.ConfigurationCache;
>  import org.apache.commons.beanutils.*;
>
>  public class MCDynaActionForm  extends DynaActionForm {
>
>  protected MCDynaClass wccDynaClass = null;
>
>  public MCDynaActionForm(){
>  wccDynaClass = new MCDynaClass(); 
>  }
>
>      public DynaClass getDynaClass() {
>          return (this.wccDynaClass);
>      }
>
>      public void set(String name, Object value) {
>  System.out.println("*********** SHAN : Set method called. Updation takes place in data object also ********** " + dataObject); 
>  System.out.println("*********** SHAN : HashValue is ********** " + hashCode()); 
>  ((MCDynaClass)getDynaClass()).add(name, value.getClass());
>          dynaValues.put(name, value);
>  if(dataObject != null){
>  String[] values = name.split(":");
>  String tableName = values[0];
>  String columnName = values[1];
>  try{
>  // This will update in all the rows that are present with this value.
>  dataObject.set(tableName, columnName, value);
>  }
>  catch(Exception e){
>  e.printStackTrace();
>  }
>  }
>      }
>
>
>      public void set(String name, int index, Object value) {
>  ((MCDynaClass)getDynaClass()).add(name, value.getClass());
>          dynaValues.put(name, value);
>      }
>
>
>      public void set(String name, String key, Object value) {
>  ((MCDynaClass)getDynaClass()).add(name, value.getClass());
>          dynaValues.put(name, value);
>      }
>
>  public DataObject dataObject = null;
>
>  public void setDataObject(Object dataObject){
>  this.dataObject = (DataObject) dataObject;
>  setFormValues();
>  }
>
>  public Object getDataObject(){
>  return dataObject;
>  }
>
>  public void setFormValues(){
>  try{
>  List tableList = dataObject.getTableNames();
>  if(tableList != null && tableList.size() > 0){
>  int size = tableList.size();
>  for(int i = 0; i < size; i++){
>  String tableName = (String) tableList.get(i);
>  Row row = dataObject.getFirstRow(tableName);
>  List columnNames = row.getColumns();
>  List columnTypes = row.getColumnTypes();
>  if(columnNames != null && columnNames.size() > 0){
>  int count = columnNames.size();
>  for(int j = 0; j < count; j++){
>  String columnName = (String) columnNames.get(j);
>  Object value = row.get(columnName);
>  set(tableName + ":" + columnName, value);
>  }
>  }
>  }
>  }
>  }
>  catch(Exception e){
>  e.printStackTrace();
>  }
>  }
>
>  public DataObject createDataObject() throws DataAccessException{
>  try{
>  DataObject createdDO = null;
>  PersistenceRemote persistenceAPI = ConfigurationCache.getPersistenceAPI();
>  createdDO = persistenceAPI.constructDataObject();
>  Iterator set = dynaValues.keySet().iterator();
>  Properties rows = new Properties();
>  Row row = null;
>  while(set.hasNext()){
>  String name = (String) set.next();
>  Object value = dynaValues.get(name);
>  String[] values = name.split(":");
>  String tableName = values[0];
>  String columnName = values[1];
>  row = (Row) rows.get(tableName);
>  if(row == null){
>  row = new Row(tableName);
>  rows.put(tableName, row);
>  }
>  row.set(columnName, value);
>  }
>  Enumeration enum = rows.propertyNames();
>  while(enum.hasMoreElements()){
>  String currentTableName = (String) enum.nextElement();
>  Row currentRow = (Row) rows.get(currentTableName);
>  createdDO.addRow(currentRow);
>  }
>  return createdDO;
>  }
>  catch(Exception e){
>  e.printStackTrace();
>  return null;
>  }
>  }
>  }
>
>
>
>
>------------------------------------------------------------------------------
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>  For additional commands, e-mail: struts-user-help@jakarta.apache.org
>  
>

Re: Populating form Elements from another object.

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Shanmugam,

I think your problem lies in the way you have defined your two actions in the struts-config.xml - one of them has scope="session" and the other doesn't, which means it will probably default to request. I think this is causing your problem because Struts only looks for the ActionForm in the scope of the mapping specified - so in your case I believe its creating two versions of "severityForm". Try addding a scope="session" to your "/severityDetails" action and see if that sorts it out.

Niall

  ----- Original Message ----- 
  From: shanmugampl 
  To: Struts Users Mailing List 
  Sent: Friday, March 12, 2004 3:55 AM
  Subject: Re: Populating form Elements from another object.


  Hi Niall,

         Thanks for your inputs. I followed your methodology with slight changes. I have a class MCDynaClass which equals your LazyDynaClass. Instead of having a separate bean as LazyDynaBean, i extended the DynaActionForm as MCDynaActionForm and overridden the set methods as per my requirement.  The entry in the struts-config.xml will be like 

  <form-beans>
      <form-bean name = "severityForm" type = "com.adventnet.client.struts.action.MCDynaActionForm"/>
  </form-beans>

  <action path = "/severityDetails" type = "com.adventnet.client.struts.action.SeverityDetailsAction"   name = "severityForm" >
     <forward name = "details" path = "/jsp/detailsPage.jsp"/>
  </action>
  <action path = "/updateSeverity" type = "com.adventnet.client.struts.action.UpdateSeverityDetailsAction" name = "severityForm" input = "/severityDetails.do" scope = "session">
        <forward name = "success" path = "/jsp/results.jsp"/>
  </action>

         In the  ActionClass i will get the DataObject(my own object) and set it to the form through the setDataObject method.

  MCDynaActionForm userForm = (MCDynaActionForm) form;
  userForm.setDataObject(newDO);

         By this way i am able to populate the values dynamically. The problems comes when i am submitting the form. When the form is submitted, the instance of the form that i am getting in the action class is different. As a result, I cannot update the dataObject as it is null. I could not figure out where i have gone wrong. I have attached my source. Kindly help me.

  Thanks
  Shanmugam PL



  Niall Pemberton wrote:

Yup, thats it - plus dynamic="true"

 <form-bean name="fooForm1"
type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
 <form-bean name="fooForm2"
type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
 <form-bean name="fooForm3"
type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
 <form-bean name="fooForm4"
type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />

Oh, I noticed an error in LazyValidatorForm, its declared as "abstract" -
which it shouldn't be - I don't use it directly, I use
LazyValidatorActionForm which extends it.

Niall


----- Original Message ----- 
From: "Mark Lowe" <ma...@talk21.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, March 09, 2004 8:53 AM
Subject: Re: Populating form Elements from another object.


  I haven't seen the code but if what i understand of what Niall has been
saying you'd  use them instead of DynaActionForm.

<form-bean name="fooForm" type="com.ilovesparrows.struts.NiallsForm" />

of course you'll need to call the package and class name to something
appropriate.

On 9 Mar 2004, at 09:47, shanmugampl wrote:

    Hi,

   I saw your code. I have one doubt. How do you plugin your own
DynaBean implementation into the struts framework.

Shanmugam PL

Niall Pemberton wrote:

      I wrote these....

http://www.niallp.pwp.blueyonder.co.uk

Niall

----- Original Message ----- From: "shanmugampl"
<sh...@adventnet.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, February 25, 2004 7:00 AM
Subject: Populating form Elements from another object.



        Hi,

     I have a requirement where i need to populate the values of a
form from another object, and then again transform the contents of
the form back to the object once the form is submitted. i.e Say,
when i click a button, i do some functionalities and have a
Properties object as an output. The keys in the Properties object
are not static. These values need to be shown in a form. As the keys
retrieved for the current operation is not known, i cant define the
values in the struts-config.xml for the dynaactionclass.

      Is it possible to extend the dynaactionclass, and during its
init or something, iterate the properties object and populate the
form.  Are there any other way of doing it.

Thanks
Shanmugam PL


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



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


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


    


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

  

------------------------------------------------------------------------------


  package com.adventnet.client.struts.action;

  import org.apache.struts.action.DynaActionForm;

  import java.lang.reflect.Array;
  import java.util.*;
  import com.adventnet.persistence.ejb.*;
  import com.adventnet.persistence.*;
  import com.adventnet.nms.ms.config.client.ConfigurationCache;
  import org.apache.commons.beanutils.*;

  public class MCDynaActionForm  extends DynaActionForm {

  protected MCDynaClass wccDynaClass = null;

  public MCDynaActionForm(){
  wccDynaClass = new MCDynaClass(); 
  }

      public DynaClass getDynaClass() {
          return (this.wccDynaClass);
      }

      public void set(String name, Object value) {
  System.out.println("*********** SHAN : Set method called. Updation takes place in data object also ********** " + dataObject); 
  System.out.println("*********** SHAN : HashValue is ********** " + hashCode()); 
  ((MCDynaClass)getDynaClass()).add(name, value.getClass());
          dynaValues.put(name, value);
  if(dataObject != null){
  String[] values = name.split(":");
  String tableName = values[0];
  String columnName = values[1];
  try{
  // This will update in all the rows that are present with this value.
  dataObject.set(tableName, columnName, value);
  }
  catch(Exception e){
  e.printStackTrace();
  }
  }
      }


      public void set(String name, int index, Object value) {
  ((MCDynaClass)getDynaClass()).add(name, value.getClass());
          dynaValues.put(name, value);
      }


      public void set(String name, String key, Object value) {
  ((MCDynaClass)getDynaClass()).add(name, value.getClass());
          dynaValues.put(name, value);
      }

  public DataObject dataObject = null;

  public void setDataObject(Object dataObject){
  this.dataObject = (DataObject) dataObject;
  setFormValues();
  }

  public Object getDataObject(){
  return dataObject;
  }

  public void setFormValues(){
  try{
  List tableList = dataObject.getTableNames();
  if(tableList != null && tableList.size() > 0){
  int size = tableList.size();
  for(int i = 0; i < size; i++){
  String tableName = (String) tableList.get(i);
  Row row = dataObject.getFirstRow(tableName);
  List columnNames = row.getColumns();
  List columnTypes = row.getColumnTypes();
  if(columnNames != null && columnNames.size() > 0){
  int count = columnNames.size();
  for(int j = 0; j < count; j++){
  String columnName = (String) columnNames.get(j);
  Object value = row.get(columnName);
  set(tableName + ":" + columnName, value);
  }
  }
  }
  }
  }
  catch(Exception e){
  e.printStackTrace();
  }
  }

  public DataObject createDataObject() throws DataAccessException{
  try{
  DataObject createdDO = null;
  PersistenceRemote persistenceAPI = ConfigurationCache.getPersistenceAPI();
  createdDO = persistenceAPI.constructDataObject();
  Iterator set = dynaValues.keySet().iterator();
  Properties rows = new Properties();
  Row row = null;
  while(set.hasNext()){
  String name = (String) set.next();
  Object value = dynaValues.get(name);
  String[] values = name.split(":");
  String tableName = values[0];
  String columnName = values[1];
  row = (Row) rows.get(tableName);
  if(row == null){
  row = new Row(tableName);
  rows.put(tableName, row);
  }
  row.set(columnName, value);
  }
  Enumeration enum = rows.propertyNames();
  while(enum.hasMoreElements()){
  String currentTableName = (String) enum.nextElement();
  Row currentRow = (Row) rows.get(currentTableName);
  createdDO.addRow(currentRow);
  }
  return createdDO;
  }
  catch(Exception e){
  e.printStackTrace();
  return null;
  }
  }
  }




------------------------------------------------------------------------------


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

Re: Populating form Elements from another object.

Posted by shanmugampl <sh...@adventnet.com>.
Hi Niall,

       Thanks for your inputs. I followed your methodology with slight 
changes. I have a class MCDynaClass which equals your LazyDynaClass. 
Instead of having a separate bean as LazyDynaBean, i extended the 
DynaActionForm as MCDynaActionForm and overridden the set methods as per 
my requirement.  The entry in the struts-config.xml will be like

*<form-beans>
    <form-bean name = "severityForm" type = 
"com.adventnet.client.struts.action.MCDynaActionForm"/>
</form-beans>
*
*<action path = "/severityDetails" type = 
"com.adventnet.client.struts.action.SeverityDetailsAction"   name = 
"severityForm" >
   <forward name = "details" path = "/jsp/detailsPage.jsp"/>
</action>
<action path = "/updateSeverity" type = 
"com.adventnet.client.struts.action.UpdateSeverityDetailsAction" name = 
"severityForm" input = "/severityDetails.do" scope = "session">
      <forward name = "success" path = "/jsp/results.jsp"/>
</action>
*
       In the  ActionClass i will get the DataObject(my own object) and 
set it to the form through the setDataObject method.

*MCDynaActionForm userForm = (MCDynaActionForm) form;
userForm.setDataObject(newDO);

       *By this way i am able to populate the values dynamically. The 
problems comes when i am submitting the form. When the form is 
submitted, the instance of the form that i am getting in the action 
class is different. As a result, I cannot update the dataObject as it is 
null. I could not figure out where i have gone wrong. I have attached my 
source. Kindly help me.

Thanks
Shanmugam PL



Niall Pemberton wrote:

>Yup, thats it - plus dynamic="true"
>
> <form-bean name="fooForm1"
>type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
> <form-bean name="fooForm2"
>type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
> <form-bean name="fooForm3"
>type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
> <form-bean name="fooForm4"
>type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
>
>Oh, I noticed an error in LazyValidatorForm, its declared as "abstract" -
>which it shouldn't be - I don't use it directly, I use
>LazyValidatorActionForm which extends it.
>
>Niall
>
>
>----- Original Message ----- 
>From: "Mark Lowe" <ma...@talk21.com>
>To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>Sent: Tuesday, March 09, 2004 8:53 AM
>Subject: Re: Populating form Elements from another object.
>
>
>  
>
>>I haven't seen the code but if what i understand of what Niall has been
>>saying you'd  use them instead of DynaActionForm.
>>
>><form-bean name="fooForm" type="com.ilovesparrows.struts.NiallsForm" />
>>
>>of course you'll need to call the package and class name to something
>>appropriate.
>>
>>On 9 Mar 2004, at 09:47, shanmugampl wrote:
>>
>>    
>>
>>>Hi,
>>>
>>>   I saw your code. I have one doubt. How do you plugin your own
>>>DynaBean implementation into the struts framework.
>>>
>>>Shanmugam PL
>>>
>>>Niall Pemberton wrote:
>>>
>>>      
>>>
>>>>I wrote these....
>>>>
>>>>http://www.niallp.pwp.blueyonder.co.uk
>>>>
>>>>Niall
>>>>
>>>>----- Original Message ----- From: "shanmugampl"
>>>><sh...@adventnet.com>
>>>>To: <st...@jakarta.apache.org>
>>>>Sent: Wednesday, February 25, 2004 7:00 AM
>>>>Subject: Populating form Elements from another object.
>>>>
>>>>
>>>>
>>>>        
>>>>
>>>>>Hi,
>>>>>
>>>>>     I have a requirement where i need to populate the values of a
>>>>>form from another object, and then again transform the contents of
>>>>>the form back to the object once the form is submitted. i.e Say,
>>>>>when i click a button, i do some functionalities and have a
>>>>>Properties object as an output. The keys in the Properties object
>>>>>are not static. These values need to be shown in a form. As the keys
>>>>>retrieved for the current operation is not known, i cant define the
>>>>>values in the struts-config.xml for the dynaactionclass.
>>>>>
>>>>>      Is it possible to extend the dynaactionclass, and during its
>>>>>init or something, iterate the properties object and populate the
>>>>>form.  Are there any other way of doing it.
>>>>>
>>>>>Thanks
>>>>>Shanmugam PL
>>>>>
>>>>>
>>>>>---------------------------------------------------------------------
>>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>>>
>>>>>          
>>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>>
>>>>        
>>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>

Re: Populating form Elements from another object.

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
I guess you could use this badly and create such a hole - but the problem
wouldn't be with LazyDynaBean, but with how you are using it.

If you have an action that doesn't validate whats in the ActionForm and
takes whatever is in there and updates your model then you've got a problem.
If I had an "update customer name" action, then my action will only take the
customer name from the ActionForm and update the model - if some smart hack
has also populated a "creditLimit" property - so what, I don't do anything
with it in my action, so there is no harm done.

An alternative to my LazyDynaBeans is the "formDef" stuff that Hubert Rabago
has done - this takes a different approach to the same kind of issues I was
trying to address with my Lazy stuff. He basically has combined and extended
form definitions from struts-config.xml and validation.xml and probably
wouldn't have the same kind of issue you are raising:

FormDef pages and downloads:
http://www.rabago.net/struts/formdef

An introduction manual is also available at
http://www.rabago.net/struts/formdef/manual.htm


Niall

----- Original Message ----- 
From: "Erez Efrati" <er...@netmedia.net.il>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Wednesday, March 10, 2004 3:25 PM
Subject: RE: Populating form Elements from another object.


It looks cool, still there´s a problem of being open to small nasty
attacks.
Since the set() method adds fields dynamically, it would do it also upon
properties population. So, when a request comes loaded with fields that
never should have been sent, the lazyDynaBean would add them, thus
creating a small hole of security. What do you think?

Erez

-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk]
Sent: Wednesday, March 10, 2004 5:20 PM
To: Struts Users Mailing List
Subject: Re: Populating form Elements from another object.

Thats it exactly. I have updated my web page with examples for LazyBean
and
LazyValidatorActionForm processing:

    http://www.niallp.pwp.blueyonder.co.uk

Niall

----- Original Message ----- 
From: "Mark Lowe" <ma...@talk21.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, March 10, 2004 8:16 AM
Subject: Re: Populating form Elements from another object.


> Again I haven't used Niall's classes but I'd hazard a guess that as
> they extend DynaBean that you use the map like interface for accessing
> these properties. In fact I imagine you can cast them as a DynaBean
> like you can with the DynaActionForms
>
> DynaBean myForm = (DynaBean) form;
> String foo = myForm.get("foo").toString();
>
>
>
> On 9 Mar 2004, at 20:27, Metin Carl wrote:
>
> > This is really good. An example of processing this form in Action
> > classes
> > would be very useful too as the way Shanmugam needs.
> >
> >
> > "Niall Pemberton" <ni...@blueyonder.co.uk> wrote in
message
> > news:025801c405f6$eb3ffef0$90af2b52@DELL1800...
> >> Yup, thats it - plus dynamic="true"
> >>
> >>  <form-bean name="fooForm1"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true"
/>
> >>  <form-bean name="fooForm2"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true"
/>
> >>  <form-bean name="fooForm3"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true"
/>
> >>  <form-bean name="fooForm4"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true"
/>
> >>
> >> Oh, I noticed an error in LazyValidatorForm, its declared as
> >> "abstract" -
> >> which it shouldn't be - I don't use it directly, I use
> >> LazyValidatorActionForm which extends it.
> >>
> >> Niall
> >>
> >>
> >> ----- Original Message -----
> >> From: "Mark Lowe" <ma...@talk21.com>
> >> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> >> Sent: Tuesday, March 09, 2004 8:53 AM
> >> Subject: Re: Populating form Elements from another object.
> >>
> >>
> >>> I haven't seen the code but if what i understand of what Niall has
> >>> been
> >>> saying you'd  use them instead of DynaActionForm.
> >>>
> >>> <form-bean name="fooForm"
type="com.ilovesparrows.struts.NiallsForm"
> >>> />
> >>>
> >>> of course you'll need to call the package and class name to
something
> >>> appropriate.
> >>>
> >>> On 9 Mar 2004, at 09:47, shanmugampl wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>>    I saw your code. I have one doubt. How do you plugin your own
> >>>> DynaBean implementation into the struts framework.
> >>>>
> >>>> Shanmugam PL
> >>>>
> >>>> Niall Pemberton wrote:
> >>>>
> >>>>> I wrote these....
> >>>>>
> >>>>> http://www.niallp.pwp.blueyonder.co.uk
> >>>>>
> >>>>> Niall
> >>>>>
> >>>>> ----- Original Message ----- From: "shanmugampl"
> >>>>> <sh...@adventnet.com>
> >>>>> To: <st...@jakarta.apache.org>
> >>>>> Sent: Wednesday, February 25, 2004 7:00 AM
> >>>>> Subject: Populating form Elements from another object.
> >>>>>
> >>>>>
> >>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>>      I have a requirement where i need to populate the values
of a
> >>>>>> form from another object, and then again transform the contents
of
> >>>>>> the form back to the object once the form is submitted. i.e
Say,
> >>>>>> when i click a button, i do some functionalities and have a
> >>>>>> Properties object as an output. The keys in the Properties
object
> >>>>>> are not static. These values need to be shown in a form. As the
> >>>>>> keys
> >>>>>> retrieved for the current operation is not known, i cant define
> >>>>>> the
> >>>>>> values in the struts-config.xml for the dynaactionclass.
> >>>>>>
> >>>>>>       Is it possible to extend the dynaactionclass, and during
its
> >>>>>> init or something, iterate the properties object and populate
the
> >>>>>> form.  Are there any other way of doing it.
> >>>>>>
> >>>>>> Thanks
> >>>>>> Shanmugam PL
> >>>>>>
> >>>>>>
> >>>
> >>>>
-------------------------------------------------------------------- 
> >>>> -
> >>>>>> To unsubscribe, e-mail:
struts-user-unsubscribe@jakarta.apache.org
> >>>>>> For additional commands, e-mail:
> >>>>>> struts-user-help@jakarta.apache.org
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
------------------------------------------------------------------- 
> >>>>> --
> >>>>> To unsubscribe, e-mail:
struts-user-unsubscribe@jakarta.apache.org
> >>>>> For additional commands, e-mail:
> >>>>> struts-user-help@jakarta.apache.org
> >>>>>
> >>>>>
> >>>
> >>>
> >>>
---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>> For additional commands, e-mail:
struts-user-help@jakarta.apache.org
> >>>
> >>>
> >
> >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



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




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



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


RE: Populating form Elements from another object.

Posted by Erez Efrati <er...@netmedia.net.il>.
It looks cool, still there´s a problem of being open to small nasty
attacks.
Since the set() method adds fields dynamically, it would do it also upon
properties population. So, when a request comes loaded with fields that
never should have been sent, the lazyDynaBean would add them, thus
creating a small hole of security. What do you think?

Erez

-----Original Message-----
From: Niall Pemberton [mailto:niall.pemberton@blueyonder.co.uk] 
Sent: Wednesday, March 10, 2004 5:20 PM
To: Struts Users Mailing List
Subject: Re: Populating form Elements from another object.

Thats it exactly. I have updated my web page with examples for LazyBean
and
LazyValidatorActionForm processing:

    http://www.niallp.pwp.blueyonder.co.uk

Niall

----- Original Message ----- 
From: "Mark Lowe" <ma...@talk21.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, March 10, 2004 8:16 AM
Subject: Re: Populating form Elements from another object.


> Again I haven't used Niall's classes but I'd hazard a guess that as
> they extend DynaBean that you use the map like interface for accessing
> these properties. In fact I imagine you can cast them as a DynaBean
> like you can with the DynaActionForms
>
> DynaBean myForm = (DynaBean) form;
> String foo = myForm.get("foo").toString();
>
>
>
> On 9 Mar 2004, at 20:27, Metin Carl wrote:
>
> > This is really good. An example of processing this form in Action
> > classes
> > would be very useful too as the way Shanmugam needs.
> >
> >
> > "Niall Pemberton" <ni...@blueyonder.co.uk> wrote in
message
> > news:025801c405f6$eb3ffef0$90af2b52@DELL1800...
> >> Yup, thats it - plus dynamic="true"
> >>
> >>  <form-bean name="fooForm1"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true"
/>
> >>  <form-bean name="fooForm2"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true"
/>
> >>  <form-bean name="fooForm3"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true"
/>
> >>  <form-bean name="fooForm4"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true"
/>
> >>
> >> Oh, I noticed an error in LazyValidatorForm, its declared as
> >> "abstract" -
> >> which it shouldn't be - I don't use it directly, I use
> >> LazyValidatorActionForm which extends it.
> >>
> >> Niall
> >>
> >>
> >> ----- Original Message -----
> >> From: "Mark Lowe" <ma...@talk21.com>
> >> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> >> Sent: Tuesday, March 09, 2004 8:53 AM
> >> Subject: Re: Populating form Elements from another object.
> >>
> >>
> >>> I haven't seen the code but if what i understand of what Niall has
> >>> been
> >>> saying you'd  use them instead of DynaActionForm.
> >>>
> >>> <form-bean name="fooForm"
type="com.ilovesparrows.struts.NiallsForm"
> >>> />
> >>>
> >>> of course you'll need to call the package and class name to
something
> >>> appropriate.
> >>>
> >>> On 9 Mar 2004, at 09:47, shanmugampl wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>>    I saw your code. I have one doubt. How do you plugin your own
> >>>> DynaBean implementation into the struts framework.
> >>>>
> >>>> Shanmugam PL
> >>>>
> >>>> Niall Pemberton wrote:
> >>>>
> >>>>> I wrote these....
> >>>>>
> >>>>> http://www.niallp.pwp.blueyonder.co.uk
> >>>>>
> >>>>> Niall
> >>>>>
> >>>>> ----- Original Message ----- From: "shanmugampl"
> >>>>> <sh...@adventnet.com>
> >>>>> To: <st...@jakarta.apache.org>
> >>>>> Sent: Wednesday, February 25, 2004 7:00 AM
> >>>>> Subject: Populating form Elements from another object.
> >>>>>
> >>>>>
> >>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>>      I have a requirement where i need to populate the values
of a
> >>>>>> form from another object, and then again transform the contents
of
> >>>>>> the form back to the object once the form is submitted. i.e
Say,
> >>>>>> when i click a button, i do some functionalities and have a
> >>>>>> Properties object as an output. The keys in the Properties
object
> >>>>>> are not static. These values need to be shown in a form. As the
> >>>>>> keys
> >>>>>> retrieved for the current operation is not known, i cant define
> >>>>>> the
> >>>>>> values in the struts-config.xml for the dynaactionclass.
> >>>>>>
> >>>>>>       Is it possible to extend the dynaactionclass, and during
its
> >>>>>> init or something, iterate the properties object and populate
the
> >>>>>> form.  Are there any other way of doing it.
> >>>>>>
> >>>>>> Thanks
> >>>>>> Shanmugam PL
> >>>>>>
> >>>>>>
> >>>
> >>>>
-------------------------------------------------------------------- 
> >>>> -
> >>>>>> To unsubscribe, e-mail:
struts-user-unsubscribe@jakarta.apache.org
> >>>>>> For additional commands, e-mail:
> >>>>>> struts-user-help@jakarta.apache.org
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
------------------------------------------------------------------- 
> >>>>> --
> >>>>> To unsubscribe, e-mail:
struts-user-unsubscribe@jakarta.apache.org
> >>>>> For additional commands, e-mail:
> >>>>> struts-user-help@jakarta.apache.org
> >>>>>
> >>>>>
> >>>
> >>>
> >>>
---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>> For additional commands, e-mail:
struts-user-help@jakarta.apache.org
> >>>
> >>>
> >
> >
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



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




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


Re: Populating form Elements from another object.

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Thats it exactly. I have updated my web page with examples for LazyBean and
LazyValidatorActionForm processing:

    http://www.niallp.pwp.blueyonder.co.uk

Niall

----- Original Message ----- 
From: "Mark Lowe" <ma...@talk21.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, March 10, 2004 8:16 AM
Subject: Re: Populating form Elements from another object.


> Again I haven't used Niall's classes but I'd hazard a guess that as
> they extend DynaBean that you use the map like interface for accessing
> these properties. In fact I imagine you can cast them as a DynaBean
> like you can with the DynaActionForms
>
> DynaBean myForm = (DynaBean) form;
> String foo = myForm.get("foo").toString();
>
>
>
> On 9 Mar 2004, at 20:27, Metin Carl wrote:
>
> > This is really good. An example of processing this form in Action
> > classes
> > would be very useful too as the way Shanmugam needs.
> >
> >
> > "Niall Pemberton" <ni...@blueyonder.co.uk> wrote in message
> > news:025801c405f6$eb3ffef0$90af2b52@DELL1800...
> >> Yup, thats it - plus dynamic="true"
> >>
> >>  <form-bean name="fooForm1"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
> >>  <form-bean name="fooForm2"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
> >>  <form-bean name="fooForm3"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
> >>  <form-bean name="fooForm4"
> >> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
> >>
> >> Oh, I noticed an error in LazyValidatorForm, its declared as
> >> "abstract" -
> >> which it shouldn't be - I don't use it directly, I use
> >> LazyValidatorActionForm which extends it.
> >>
> >> Niall
> >>
> >>
> >> ----- Original Message -----
> >> From: "Mark Lowe" <ma...@talk21.com>
> >> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> >> Sent: Tuesday, March 09, 2004 8:53 AM
> >> Subject: Re: Populating form Elements from another object.
> >>
> >>
> >>> I haven't seen the code but if what i understand of what Niall has
> >>> been
> >>> saying you'd  use them instead of DynaActionForm.
> >>>
> >>> <form-bean name="fooForm" type="com.ilovesparrows.struts.NiallsForm"
> >>> />
> >>>
> >>> of course you'll need to call the package and class name to something
> >>> appropriate.
> >>>
> >>> On 9 Mar 2004, at 09:47, shanmugampl wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>>    I saw your code. I have one doubt. How do you plugin your own
> >>>> DynaBean implementation into the struts framework.
> >>>>
> >>>> Shanmugam PL
> >>>>
> >>>> Niall Pemberton wrote:
> >>>>
> >>>>> I wrote these....
> >>>>>
> >>>>> http://www.niallp.pwp.blueyonder.co.uk
> >>>>>
> >>>>> Niall
> >>>>>
> >>>>> ----- Original Message ----- From: "shanmugampl"
> >>>>> <sh...@adventnet.com>
> >>>>> To: <st...@jakarta.apache.org>
> >>>>> Sent: Wednesday, February 25, 2004 7:00 AM
> >>>>> Subject: Populating form Elements from another object.
> >>>>>
> >>>>>
> >>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>>      I have a requirement where i need to populate the values of a
> >>>>>> form from another object, and then again transform the contents of
> >>>>>> the form back to the object once the form is submitted. i.e Say,
> >>>>>> when i click a button, i do some functionalities and have a
> >>>>>> Properties object as an output. The keys in the Properties object
> >>>>>> are not static. These values need to be shown in a form. As the
> >>>>>> keys
> >>>>>> retrieved for the current operation is not known, i cant define
> >>>>>> the
> >>>>>> values in the struts-config.xml for the dynaactionclass.
> >>>>>>
> >>>>>>       Is it possible to extend the dynaactionclass, and during its
> >>>>>> init or something, iterate the properties object and populate the
> >>>>>> form.  Are there any other way of doing it.
> >>>>>>
> >>>>>> Thanks
> >>>>>> Shanmugam PL
> >>>>>>
> >>>>>>
> >>>
> >>>> -------------------------------------------------------------------- 
> >>>> -
> >>>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>>>>> For additional commands, e-mail:
> >>>>>> struts-user-help@jakarta.apache.org
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>> ------------------------------------------------------------------- 
> >>>>> --
> >>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>>>> For additional commands, e-mail:
> >>>>> struts-user-help@jakarta.apache.org
> >>>>>
> >>>>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>>
> >>>
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



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


Re: Populating form Elements from another object.

Posted by Mark Lowe <ma...@talk21.com>.
Again I haven't used Niall's classes but I'd hazard a guess that as  
they extend DynaBean that you use the map like interface for accessing  
these properties. In fact I imagine you can cast them as a DynaBean  
like you can with the DynaActionForms

DynaBean myForm = (DynaBean) form;
String foo = myForm.get("foo").toString();



On 9 Mar 2004, at 20:27, Metin Carl wrote:

> This is really good. An example of processing this form in Action  
> classes
> would be very useful too as the way Shanmugam needs.
>
>
> "Niall Pemberton" <ni...@blueyonder.co.uk> wrote in message
> news:025801c405f6$eb3ffef0$90af2b52@DELL1800...
>> Yup, thats it - plus dynamic="true"
>>
>>  <form-bean name="fooForm1"
>> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
>>  <form-bean name="fooForm2"
>> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
>>  <form-bean name="fooForm3"
>> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
>>  <form-bean name="fooForm4"
>> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
>>
>> Oh, I noticed an error in LazyValidatorForm, its declared as  
>> "abstract" -
>> which it shouldn't be - I don't use it directly, I use
>> LazyValidatorActionForm which extends it.
>>
>> Niall
>>
>>
>> ----- Original Message -----
>> From: "Mark Lowe" <ma...@talk21.com>
>> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
>> Sent: Tuesday, March 09, 2004 8:53 AM
>> Subject: Re: Populating form Elements from another object.
>>
>>
>>> I haven't seen the code but if what i understand of what Niall has  
>>> been
>>> saying you'd  use them instead of DynaActionForm.
>>>
>>> <form-bean name="fooForm" type="com.ilovesparrows.struts.NiallsForm"  
>>> />
>>>
>>> of course you'll need to call the package and class name to something
>>> appropriate.
>>>
>>> On 9 Mar 2004, at 09:47, shanmugampl wrote:
>>>
>>>> Hi,
>>>>
>>>>    I saw your code. I have one doubt. How do you plugin your own
>>>> DynaBean implementation into the struts framework.
>>>>
>>>> Shanmugam PL
>>>>
>>>> Niall Pemberton wrote:
>>>>
>>>>> I wrote these....
>>>>>
>>>>> http://www.niallp.pwp.blueyonder.co.uk
>>>>>
>>>>> Niall
>>>>>
>>>>> ----- Original Message ----- From: "shanmugampl"
>>>>> <sh...@adventnet.com>
>>>>> To: <st...@jakarta.apache.org>
>>>>> Sent: Wednesday, February 25, 2004 7:00 AM
>>>>> Subject: Populating form Elements from another object.
>>>>>
>>>>>
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>>      I have a requirement where i need to populate the values of a
>>>>>> form from another object, and then again transform the contents of
>>>>>> the form back to the object once the form is submitted. i.e Say,
>>>>>> when i click a button, i do some functionalities and have a
>>>>>> Properties object as an output. The keys in the Properties object
>>>>>> are not static. These values need to be shown in a form. As the  
>>>>>> keys
>>>>>> retrieved for the current operation is not known, i cant define  
>>>>>> the
>>>>>> values in the struts-config.xml for the dynaactionclass.
>>>>>>
>>>>>>       Is it possible to extend the dynaactionclass, and during its
>>>>>> init or something, iterate the properties object and populate the
>>>>>> form.  Are there any other way of doing it.
>>>>>>
>>>>>> Thanks
>>>>>> Shanmugam PL
>>>>>>
>>>>>>
>>>
>>>> -------------------------------------------------------------------- 
>>>> -
>>>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>>> For additional commands, e-mail:  
>>>>>> struts-user-help@jakarta.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------- 
>>>>> --
>>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>>> For additional commands, e-mail:  
>>>>> struts-user-help@jakarta.apache.org
>>>>>
>>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: Populating form Elements from another object.

Posted by Metin Carl <me...@yahoo.com>.
This is really good. An example of processing this form in Action classes
would be very useful too as the way Shanmugam needs.


"Niall Pemberton" <ni...@blueyonder.co.uk> wrote in message
news:025801c405f6$eb3ffef0$90af2b52@DELL1800...
> Yup, thats it - plus dynamic="true"
>
>  <form-bean name="fooForm1"
> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
>  <form-bean name="fooForm2"
> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
>  <form-bean name="fooForm3"
> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
>  <form-bean name="fooForm4"
> type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
>
> Oh, I noticed an error in LazyValidatorForm, its declared as "abstract" -
> which it shouldn't be - I don't use it directly, I use
> LazyValidatorActionForm which extends it.
>
> Niall
>
>
> ----- Original Message ----- 
> From: "Mark Lowe" <ma...@talk21.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Tuesday, March 09, 2004 8:53 AM
> Subject: Re: Populating form Elements from another object.
>
>
> > I haven't seen the code but if what i understand of what Niall has been
> > saying you'd  use them instead of DynaActionForm.
> >
> > <form-bean name="fooForm" type="com.ilovesparrows.struts.NiallsForm" />
> >
> > of course you'll need to call the package and class name to something
> > appropriate.
> >
> > On 9 Mar 2004, at 09:47, shanmugampl wrote:
> >
> > > Hi,
> > >
> > >    I saw your code. I have one doubt. How do you plugin your own
> > > DynaBean implementation into the struts framework.
> > >
> > > Shanmugam PL
> > >
> > > Niall Pemberton wrote:
> > >
> > >> I wrote these....
> > >>
> > >> http://www.niallp.pwp.blueyonder.co.uk
> > >>
> > >> Niall
> > >>
> > >> ----- Original Message ----- From: "shanmugampl"
> > >> <sh...@adventnet.com>
> > >> To: <st...@jakarta.apache.org>
> > >> Sent: Wednesday, February 25, 2004 7:00 AM
> > >> Subject: Populating form Elements from another object.
> > >>
> > >>
> > >>
> > >>> Hi,
> > >>>
> > >>>      I have a requirement where i need to populate the values of a
> > >>> form from another object, and then again transform the contents of
> > >>> the form back to the object once the form is submitted. i.e Say,
> > >>> when i click a button, i do some functionalities and have a
> > >>> Properties object as an output. The keys in the Properties object
> > >>> are not static. These values need to be shown in a form. As the keys
> > >>> retrieved for the current operation is not known, i cant define the
> > >>> values in the struts-config.xml for the dynaactionclass.
> > >>>
> > >>>       Is it possible to extend the dynaactionclass, and during its
> > >>> init or something, iterate the properties object and populate the
> > >>> form.  Are there any other way of doing it.
> > >>>
> > >>> Thanks
> > >>> Shanmugam PL
> > >>>
> > >>>
> >
>>> ---------------------------------------------------------------------
> > >>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > >>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >>>
> > >>>
> > >>>
> > >>
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > >> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > >>
> > >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >




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


Re: Populating form Elements from another object.

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
Yup, thats it - plus dynamic="true"

 <form-bean name="fooForm1"
type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
 <form-bean name="fooForm2"
type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
 <form-bean name="fooForm3"
type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />
 <form-bean name="fooForm4"
type="lib.framework.struts.LazyValidatorActionForm" dynamic="true" />

Oh, I noticed an error in LazyValidatorForm, its declared as "abstract" -
which it shouldn't be - I don't use it directly, I use
LazyValidatorActionForm which extends it.

Niall


----- Original Message ----- 
From: "Mark Lowe" <ma...@talk21.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Tuesday, March 09, 2004 8:53 AM
Subject: Re: Populating form Elements from another object.


> I haven't seen the code but if what i understand of what Niall has been
> saying you'd  use them instead of DynaActionForm.
>
> <form-bean name="fooForm" type="com.ilovesparrows.struts.NiallsForm" />
>
> of course you'll need to call the package and class name to something
> appropriate.
>
> On 9 Mar 2004, at 09:47, shanmugampl wrote:
>
> > Hi,
> >
> >    I saw your code. I have one doubt. How do you plugin your own
> > DynaBean implementation into the struts framework.
> >
> > Shanmugam PL
> >
> > Niall Pemberton wrote:
> >
> >> I wrote these....
> >>
> >> http://www.niallp.pwp.blueyonder.co.uk
> >>
> >> Niall
> >>
> >> ----- Original Message ----- From: "shanmugampl"
> >> <sh...@adventnet.com>
> >> To: <st...@jakarta.apache.org>
> >> Sent: Wednesday, February 25, 2004 7:00 AM
> >> Subject: Populating form Elements from another object.
> >>
> >>
> >>
> >>> Hi,
> >>>
> >>>      I have a requirement where i need to populate the values of a
> >>> form from another object, and then again transform the contents of
> >>> the form back to the object once the form is submitted. i.e Say,
> >>> when i click a button, i do some functionalities and have a
> >>> Properties object as an output. The keys in the Properties object
> >>> are not static. These values need to be shown in a form. As the keys
> >>> retrieved for the current operation is not known, i cant define the
> >>> values in the struts-config.xml for the dynaactionclass.
> >>>
> >>>       Is it possible to extend the dynaactionclass, and during its
> >>> init or something, iterate the properties object and populate the
> >>> form.  Are there any other way of doing it.
> >>>
> >>> Thanks
> >>> Shanmugam PL
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>>
> >>>
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



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


Re: Populating form Elements from another object.

Posted by Mark Lowe <ma...@talk21.com>.
I haven't seen the code but if what i understand of what Niall has been 
saying you'd  use them instead of DynaActionForm.

<form-bean name="fooForm" type="com.ilovesparrows.struts.NiallsForm" />

of course you'll need to call the package and class name to something 
appropriate.

On 9 Mar 2004, at 09:47, shanmugampl wrote:

> Hi,
>
>    I saw your code. I have one doubt. How do you plugin your own 
> DynaBean implementation into the struts framework.
>
> Shanmugam PL
>
> Niall Pemberton wrote:
>
>> I wrote these....
>>
>> http://www.niallp.pwp.blueyonder.co.uk
>>
>> Niall
>>
>> ----- Original Message ----- From: "shanmugampl" 
>> <sh...@adventnet.com>
>> To: <st...@jakarta.apache.org>
>> Sent: Wednesday, February 25, 2004 7:00 AM
>> Subject: Populating form Elements from another object.
>>
>>
>>
>>> Hi,
>>>
>>>      I have a requirement where i need to populate the values of a 
>>> form from another object, and then again transform the contents of 
>>> the form back to the object once the form is submitted. i.e Say, 
>>> when i click a button, i do some functionalities and have a 
>>> Properties object as an output. The keys in the Properties object 
>>> are not static. These values need to be shown in a form. As the keys 
>>> retrieved for the current operation is not known, i cant define the 
>>> values in the struts-config.xml for the dynaactionclass.
>>>
>>>       Is it possible to extend the dynaactionclass, and during its 
>>> init or something, iterate the properties object and populate the 
>>> form.  Are there any other way of doing it.
>>>
>>> Thanks
>>> Shanmugam PL
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>


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