Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-25 Thread R Balaji
Adam,

Even, i know the nature of all the attributes during design time itself. 
Assume, i have 50 attributes in general, i know how to validate each one 
of them, during design time. But, for a particular kind of Business 
object, i would be getting just 20 properties alone, and the rest of the 
properties will not be applicable to the business object. Thats why i 
was facing problem, while contructing the bean.

I think, with struts-validator, i can define all the possible rules for 
the bean. I have to give a try ...

Thanks,
R Balaji
Adam Hardy wrote:

Concerning the validation, what you do depends on whether all the 
possible different validation mechanisms are limited to a defined set, 
or whether it is an unbounded set that you cannot limit at design time.

On 08/24/2003 07:06 AM R Balaji wrote:

well, in the jsp, i would be getting all the dynaproperties.. and be 
enumerating them while printing the keys and values in the UI. I 
managed to to do this, and able to display the bean details.

I too realized that i should handle the reset method. I will try that.

Yes, my business tier will give the information regarding the valid 
values of each attribute. I believe that i can use this for 
validating the properties. But i too do not know how far i can use 
dynavalidator and the validation framework.

Do you have any suggestions other than my  current dynamic bean 
population design ?.

Regards,
R Balaji


Adam Hardy wrote:

I read your solution for populating the dynaform. How do you display 
it in JSP? I mean, how does the JSP know what the field names are?

I don't really know the internal workings of the dynavalidator form 
and how struts would populate the form bean with request parameters. 
You would probably have to do the same formbean initialization in 
the bean's reset method, otherwise the request parameters will 
probably not get saved to it.

Once you get that far, then validation becomes an issue. At design 
time you don't what the fields of a form will be - but do you know 
how any particular type of field should be validated? If so, how do 
you know? Is that in the design?

Adam

On 08/23/2003 05:34 PM R Balaji wrote:

Yes, Adam .. this is a valid point , that i need to consider.

But, it is almost impossible to define a bean for each type of 
data, in my application. I need to use the dynabean and dynaclass , 
some how.

I managed to find a solution for populating the bean ,  now i have 
to find a solution for validation too.

Suggest me  a suitable validation approach..

With Regards,
R Balaji
Adam Hardy wrote:

I can see that you could just iterate over the unknown form 
properties in the JSP, but how would you label them? And when the 
form is submitted, how would you validate them?

I think you would be better advised to add your list of properties 
as beans to your form. In each bean you could also have a label 
and a validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not 
sure  why you've a problem with just adding the fields to you 
form bean in  struts config. I've demonstrated how to literally 
do what you want, but  you'd have to specify the properties you 
want in you jsp anyway. But  here goes

You could create a new form bean copy the properties across from 
you  old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler 
that  using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna 
properties,  having a DynaProperty[] array and then use the 
dynaBean constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, 
which can  not be decided at design time. I would like to 
populate the Business  data into a dynaValidatorForm and display 
them.

In this case, it is not possible to  specify all the properties 
as  form-property. If i set  properties, without specifying 
them in the  struts-config.xml, i am getting exception as 
mentioned below.

java.lang.IllegalArgumentException: Invalid property name  
'statusChangeTime'
at  
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. 
java:598)
at  
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412) 

at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV 
iewBean(ObjectDetailsHandler.java:63)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje 
ctDetails(ObjectDetailsHandler.java:49)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob 
jectDetailsAction.java:54)

Please help me , in this regards,

Thanks in 

Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-25 Thread R Balaji
Mark,

This approach looks nice. Did you consider, populating the bean, on form 
submit ? ... one more thing is.. will the struts-validator go well with 
this ?

R Balaji

Mark Lowe wrote:

Okay .. I've been thinking about this.

I think it might work something like this..

form-property name=beans property=java.util.ArrayList /

The arrayList will be a container for your beans with indexed  
properties.

So in jsp we're thinking, or aiming for

logic:iterate id=bean name=myForm property=beans
bean:write name=bean property=key[%= index %] /
html:text name=bean property=value[%= index %]  /
/logic:iterate
So we have a bean thats mapped backed, or something here's some 
pseudo  code.

public class MyBean {

private Map map;

public Object[] getKeys() {
return map.keySet().toArray();
}

public Object[] getValues() {
ArrayList list = new ArrayList();
Object[] keys = getKeys();
   
for(int i = 0;i  keys.length;i++) {
String value = map.get(keys[i].toString());
list.add(value);
}
   
return list.toArray();
}

public String getKey(int i) {
return keys[i].toString();   
}

public String getValue(int i) {
String key = getKey(i);
return map.get(key);
}

public void setKey(int i, String str) {
keys[i] = str;
}
public void setValue(int i , String str) {
map.put(getKey(i),str);
}
...
well you get the idea..
Am I tree barking, smoking crack or something but Its starting look  
possible.. el should help move the scriptlets out, but using indexed,  
mapped properties looks like it may do the job.. the bean could have 
a  double sided array it returns to keep the keys and values in the  
correct order. The keys are after all the illusion that the 
properties  have names, when really they are associated via index. 
When it comes  time to write to a db or something the bean could 
return a map and the  key=value pairs should all be there ready.

Cheers mark

On Saturday, August 23, 2003, at 06:51 PM, Adam Hardy wrote:

I read your solution for populating the dynaform. How do you display  
it in JSP? I mean, how does the JSP know what the field names are?

I don't really know the internal workings of the dynavalidator form  
and how struts would populate the form bean with request parameters.  
You would probably have to do the same formbean initialization in 
the  bean's reset method, otherwise the request parameters will 
probably  not get saved to it.

Once you get that far, then validation becomes an issue. At design  
time you don't what the fields of a form will be - but do you know 
how  any particular type of field should be validated? If so, how do 
you  know? Is that in the design?

Adam

On 08/23/2003 05:34 PM R Balaji wrote:

Yes, Adam .. this is a valid point , that i need to consider.
But, it is almost impossible to define a bean for each type of 
data,  in my application. I need to use the dynabean and dynaclass , 
some  how.
I managed to find a solution for populating the bean ,  now i have 
to  find a solution for validation too.
Suggest me  a suitable validation approach..
With Regards,
R Balaji
Adam Hardy wrote:

I can see that you could just iterate over the unknown form  
properties in the JSP, but how would you label them? And when the  
form is submitted, how would you validate them?

I think you would be better advised to add your list of properties  
as beans to your form. In each bean you could also have a label 
and  a validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not  
sure  why you've a problem with just adding the fields to you 
form  bean in  struts config. I've demonstrated how to literally 
do what  you want, but  you'd have to specify the properties you 
want in you  jsp anyway. But  here goes

You could create a new form bean copy the properties across from  
you  old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler  
that  using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna  
properties,  having a DynaProperty[] array and then use the  
dynaBean constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, 
which  can  not be decided at design time. I would like to 
populate the  Business  data into a dynaValidatorForm and display 
them.

In this case, it is not possible to  specify all the properties 
as   form-property. If i set  properties, without specifying 
them in  the  struts-config.xml, i am 

Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-25 Thread Adam Hardy
The struts-validator configuration xml requires you to name the form 
fields to be validated and the validation it depends on, at design time.

I am not sure about this, but it might be possible to define your 
validation to do all possible validations on a form bean. I haven't 
tried putting extra fields in a validation.xml that aren't present in 
the struts-config form definition. Perhaps it's possible, perhaps it 
will fail.

It won't be too difficult though to write your own validate routine, and 
just drop the validator. I assume you are not so ambitious to want 
javascript validation as well!

Adam

On 08/25/2003 05:13 AM R Balaji wrote:
Mark,

This approach looks nice. Did you consider, populating the bean, on form 
submit ? ... one more thing is.. will the struts-validator go well with 
this ?

R Balaji

Mark Lowe wrote:

Okay .. I've been thinking about this.

I think it might work something like this..

form-property name=beans property=java.util.ArrayList /

The arrayList will be a container for your beans with indexed  
properties.

So in jsp we're thinking, or aiming for

logic:iterate id=bean name=myForm property=beans
bean:write name=bean property=key[%= index %] /
html:text name=bean property=value[%= index %]  /
/logic:iterate
So we have a bean thats mapped backed, or something here's some 
pseudo  code.

public class MyBean {

private Map map;

public Object[] getKeys() {
return map.keySet().toArray();
}
public Object[] getValues() {
ArrayList list = new ArrayList();
Object[] keys = getKeys();
   for(int i = 0;i  keys.length;i++) {
String value = map.get(keys[i].toString());
list.add(value);
}
   return list.toArray();
}
public String getKey(int i) {
return keys[i].toString();   }
public String getValue(int i) {
String key = getKey(i);
return map.get(key);
}
public void setKey(int i, String str) {
keys[i] = str;
}
public void setValue(int i , String str) {
map.put(getKey(i),str);
}
...
well you get the idea..
Am I tree barking, smoking crack or something but Its starting look  
possible.. el should help move the scriptlets out, but using indexed,  
mapped properties looks like it may do the job.. the bean could have 
a  double sided array it returns to keep the keys and values in the  
correct order. The keys are after all the illusion that the 
properties  have names, when really they are associated via index. 
When it comes  time to write to a db or something the bean could 
return a map and the  key=value pairs should all be there ready.

Cheers mark

On Saturday, August 23, 2003, at 06:51 PM, Adam Hardy wrote:

I read your solution for populating the dynaform. How do you display  
it in JSP? I mean, how does the JSP know what the field names are?

I don't really know the internal workings of the dynavalidator form  
and how struts would populate the form bean with request parameters.  
You would probably have to do the same formbean initialization in 
the  bean's reset method, otherwise the request parameters will 
probably  not get saved to it.

Once you get that far, then validation becomes an issue. At design  
time you don't what the fields of a form will be - but do you know 
how  any particular type of field should be validated? If so, how do 
you  know? Is that in the design?

Adam

On 08/23/2003 05:34 PM R Balaji wrote:

Yes, Adam .. this is a valid point , that i need to consider.
But, it is almost impossible to define a bean for each type of 
data,  in my application. I need to use the dynabean and dynaclass , 
some  how.
I managed to find a solution for populating the bean ,  now i have 
to  find a solution for validation too.
Suggest me  a suitable validation approach..
With Regards,
R Balaji
Adam Hardy wrote:

I can see that you could just iterate over the unknown form  
properties in the JSP, but how would you label them? And when the  
form is submitted, how would you validate them?

I think you would be better advised to add your list of properties  
as beans to your form. In each bean you could also have a label 
and  a validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not  
sure  why you've a problem with just adding the fields to you 
form  bean in  struts config. I've demonstrated how to literally 
do what  you want, but  you'd have to specify the properties you 
want in you  jsp anyway. But  here goes

You could create a new form bean copy the properties across from  
you  old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler  
that  using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();


Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-25 Thread Adam Hardy
sorry, I meant to say regarding validation, if you try defining 50 form 
fields in a validation.xml, then you have to have 50 names. You would 
also have to copy and paste the whole form definition for each form. 
Sounds less and less like a good idea, if it even works.

On 08/25/2003 05:13 AM R Balaji wrote:
Mark,

This approach looks nice. Did you consider, populating the bean, on form 
submit ? ... one more thing is.. will the struts-validator go well with 
this ?

R Balaji

Mark Lowe wrote:

Okay .. I've been thinking about this.

I think it might work something like this..

form-property name=beans property=java.util.ArrayList /

The arrayList will be a container for your beans with indexed  
properties.

So in jsp we're thinking, or aiming for

logic:iterate id=bean name=myForm property=beans
bean:write name=bean property=key[%= index %] /
html:text name=bean property=value[%= index %]  /
/logic:iterate
So we have a bean thats mapped backed, or something here's some 
pseudo  code.

public class MyBean {

private Map map;

public Object[] getKeys() {
return map.keySet().toArray();
}
public Object[] getValues() {
ArrayList list = new ArrayList();
Object[] keys = getKeys();
   for(int i = 0;i  keys.length;i++) {
String value = map.get(keys[i].toString());
list.add(value);
}
   return list.toArray();
}
public String getKey(int i) {
return keys[i].toString();   }
public String getValue(int i) {
String key = getKey(i);
return map.get(key);
}
public void setKey(int i, String str) {
keys[i] = str;
}
public void setValue(int i , String str) {
map.put(getKey(i),str);
}
...
well you get the idea..
Am I tree barking, smoking crack or something but Its starting look  
possible.. el should help move the scriptlets out, but using indexed,  
mapped properties looks like it may do the job.. the bean could have 
a  double sided array it returns to keep the keys and values in the  
correct order. The keys are after all the illusion that the 
properties  have names, when really they are associated via index. 
When it comes  time to write to a db or something the bean could 
return a map and the  key=value pairs should all be there ready.

Cheers mark

On Saturday, August 23, 2003, at 06:51 PM, Adam Hardy wrote:

I read your solution for populating the dynaform. How do you display  
it in JSP? I mean, how does the JSP know what the field names are?

I don't really know the internal workings of the dynavalidator form  
and how struts would populate the form bean with request parameters.  
You would probably have to do the same formbean initialization in 
the  bean's reset method, otherwise the request parameters will 
probably  not get saved to it.

Once you get that far, then validation becomes an issue. At design  
time you don't what the fields of a form will be - but do you know 
how  any particular type of field should be validated? If so, how do 
you  know? Is that in the design?

Adam

On 08/23/2003 05:34 PM R Balaji wrote:

Yes, Adam .. this is a valid point , that i need to consider.
But, it is almost impossible to define a bean for each type of 
data,  in my application. I need to use the dynabean and dynaclass , 
some  how.
I managed to find a solution for populating the bean ,  now i have 
to  find a solution for validation too.
Suggest me  a suitable validation approach..
With Regards,
R Balaji
Adam Hardy wrote:

I can see that you could just iterate over the unknown form  
properties in the JSP, but how would you label them? And when the  
form is submitted, how would you validate them?

I think you would be better advised to add your list of properties  
as beans to your form. In each bean you could also have a label 
and  a validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not  
sure  why you've a problem with just adding the fields to you 
form  bean in  struts config. I've demonstrated how to literally 
do what  you want, but  you'd have to specify the properties you 
want in you  jsp anyway. But  here goes

You could create a new form bean copy the properties across from  
you  old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler  
that  using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna  
properties,  having a DynaProperty[] array and then use the  
dynaBean constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, 

Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-25 Thread Mark Lowe
You cant expect struts validator to do all the work, its nice and shows  
you how to get started. But yes you'd have to use the validator libs  
and get that running yourself. I wouldn't  build a form around the  
limitations of validator. I'll have to get the time to try this out and  
iron out the wrinkles.

No populating the form in submit i don't think will work as the  
dynaform need to the size of the property, before the page loads.

I'd approach the validator as a separate problem. You'll need to read  
the commons validator stuff and work that out another day. Validator  
can be layered on afterwards, and i'd suggest you'll have enough on  
your hands getting something like this running.

Cheers Mark

On Monday, August 25, 2003, at 08:29 AM, Adam Hardy wrote:

sorry, I meant to say regarding validation, if you try defining 50  
form fields in a validation.xml, then you have to have 50 names. You  
would also have to copy and paste the whole form definition for each  
form. Sounds less and less like a good idea, if it even works.

On 08/25/2003 05:13 AM R Balaji wrote:
Mark,
This approach looks nice. Did you consider, populating the bean, on  
form submit ? ... one more thing is.. will the struts-validator go  
well with this ?
R Balaji
Mark Lowe wrote:
Okay .. I've been thinking about this.

I think it might work something like this..

form-property name=beans property=java.util.ArrayList /

The arrayList will be a container for your beans with indexed   
properties.

So in jsp we're thinking, or aiming for

logic:iterate id=bean name=myForm property=beans
bean:write name=bean property=key[%= index %] /
html:text name=bean property=value[%= index %]  /
/logic:iterate
So we have a bean thats mapped backed, or something here's some  
pseudo  code.

public class MyBean {

private Map map;

public Object[] getKeys() {
return map.keySet().toArray();
}
public Object[] getValues() {
ArrayList list = new ArrayList();
Object[] keys = getKeys();
   for(int i = 0;i  keys.length;i++) {
String value = map.get(keys[i].toString());
list.add(value);
}
   return list.toArray();
}
public String getKey(int i) {
return keys[i].toString();   }
public String getValue(int i) {
String key = getKey(i);
return map.get(key);
}
public void setKey(int i, String str) {
keys[i] = str;
}
public void setValue(int i , String str) {
map.put(getKey(i),str);
}
...
well you get the idea..
Am I tree barking, smoking crack or something but Its starting look   
possible.. el should help move the scriptlets out, but using  
indexed,  mapped properties looks like it may do the job.. the bean  
could have a  double sided array it returns to keep the keys and  
values in the  correct order. The keys are after all the illusion  
that the properties  have names, when really they are associated via  
index. When it comes  time to write to a db or something the bean  
could return a map and the  key=value pairs should all be there  
ready.

Cheers mark

On Saturday, August 23, 2003, at 06:51 PM, Adam Hardy wrote:

I read your solution for populating the dynaform. How do you  
display  it in JSP? I mean, how does the JSP know what the field  
names are?

I don't really know the internal workings of the dynavalidator form  
 and how struts would populate the form bean with request  
parameters.  You would probably have to do the same formbean  
initialization in the  bean's reset method, otherwise the request  
parameters will probably  not get saved to it.

Once you get that far, then validation becomes an issue. At design   
time you don't what the fields of a form will be - but do you know  
how  any particular type of field should be validated? If so, how  
do you  know? Is that in the design?

Adam

On 08/23/2003 05:34 PM R Balaji wrote:

Yes, Adam .. this is a valid point , that i need to consider.
But, it is almost impossible to define a bean for each type of  
data,  in my application. I need to use the dynabean and dynaclass  
, some  how.
I managed to find a solution for populating the bean ,  now i have  
to  find a solution for validation too.
Suggest me  a suitable validation approach..
With Regards,
R Balaji
Adam Hardy wrote:

I can see that you could just iterate over the unknown form   
properties in the JSP, but how would you label them? And when the  
 form is submitted, how would you validate them?

I think you would be better advised to add your list of  
properties  as beans to your form. In each bean you could also  
have a label and  a validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not   
sure  why you've a problem with just adding the fields to you  
form  bean in  struts config. I've demonstrated how to literally  
do what  you want, but  you'd have to 

Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-24 Thread R Balaji
well, in the jsp, i would be getting all the dynaproperties.. and be 
enumerating them while printing the keys and values in the UI. I managed 
to to do this, and able to display the bean details.

I too realized that i should handle the reset method. I will try that.

Yes, my business tier will give the information regarding the valid 
values of each attribute. I believe that i can use this for validating 
the properties. But i too do not know how far i can use dynavalidator 
and the validation framework.

Do you have any suggestions other than my  current dynamic bean 
population design ?.

Regards,
R Balaji


Adam Hardy wrote:

I read your solution for populating the dynaform. How do you display 
it in JSP? I mean, how does the JSP know what the field names are?

I don't really know the internal workings of the dynavalidator form 
and how struts would populate the form bean with request parameters. 
You would probably have to do the same formbean initialization in the 
bean's reset method, otherwise the request parameters will probably 
not get saved to it.

Once you get that far, then validation becomes an issue. At design 
time you don't what the fields of a form will be - but do you know how 
any particular type of field should be validated? If so, how do you 
know? Is that in the design?

Adam

On 08/23/2003 05:34 PM R Balaji wrote:

Yes, Adam .. this is a valid point , that i need to consider.

But, it is almost impossible to define a bean for each type of data, 
in my application. I need to use the dynabean and dynaclass , some how.

I managed to find a solution for populating the bean ,  now i have to 
find a solution for validation too.

Suggest me  a suitable validation approach..

With Regards,
R Balaji
Adam Hardy wrote:

I can see that you could just iterate over the unknown form 
properties in the JSP, but how would you label them? And when the 
form is submitted, how would you validate them?

I think you would be better advised to add your list of properties 
as beans to your form. In each bean you could also have a label and 
a validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not 
sure  why you've a problem with just adding the fields to you form 
bean in  struts config. I've demonstrated how to literally do what 
you want, but  you'd have to specify the properties you want in you 
jsp anyway. But  here goes

You could create a new form bean copy the properties across from 
you  old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler 
that  using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna 
properties,  having a DynaProperty[] array and then use the 
dynaBean constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which 
can  not be decided at design time. I would like to populate the 
Business  data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties 
as  form-property. If i set  properties, without specifying them 
in the  struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name  
'statusChangeTime'
at  
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. 
java:598)
at  
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV 
iewBean(ObjectDetailsHandler.java:63)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje 
ctDetails(ObjectDetailsHandler.java:49)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob 
jectDetailsAction.java:54)

Please help me , in this regards,

Thanks in Advance.
With Regards,
R Balaji
-
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: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-24 Thread Adam Hardy
Concerning the validation, what you do depends on whether all the 
possible different validation mechanisms are limited to a defined set, 
or whether it is an unbounded set that you cannot limit at design time.

On 08/24/2003 07:06 AM R Balaji wrote:
well, in the jsp, i would be getting all the dynaproperties.. and be 
enumerating them while printing the keys and values in the UI. I managed 
to to do this, and able to display the bean details.

I too realized that i should handle the reset method. I will try that.

Yes, my business tier will give the information regarding the valid 
values of each attribute. I believe that i can use this for validating 
the properties. But i too do not know how far i can use dynavalidator 
and the validation framework.

Do you have any suggestions other than my  current dynamic bean 
population design ?.

Regards,
R Balaji


Adam Hardy wrote:

I read your solution for populating the dynaform. How do you display 
it in JSP? I mean, how does the JSP know what the field names are?

I don't really know the internal workings of the dynavalidator form 
and how struts would populate the form bean with request parameters. 
You would probably have to do the same formbean initialization in the 
bean's reset method, otherwise the request parameters will probably 
not get saved to it.

Once you get that far, then validation becomes an issue. At design 
time you don't what the fields of a form will be - but do you know how 
any particular type of field should be validated? If so, how do you 
know? Is that in the design?

Adam

On 08/23/2003 05:34 PM R Balaji wrote:

Yes, Adam .. this is a valid point , that i need to consider.

But, it is almost impossible to define a bean for each type of data, 
in my application. I need to use the dynabean and dynaclass , some how.

I managed to find a solution for populating the bean ,  now i have to 
find a solution for validation too.

Suggest me  a suitable validation approach..

With Regards,
R Balaji
Adam Hardy wrote:

I can see that you could just iterate over the unknown form 
properties in the JSP, but how would you label them? And when the 
form is submitted, how would you validate them?

I think you would be better advised to add your list of properties 
as beans to your form. In each bean you could also have a label and 
a validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not 
sure  why you've a problem with just adding the fields to you form 
bean in  struts config. I've demonstrated how to literally do what 
you want, but  you'd have to specify the properties you want in you 
jsp anyway. But  here goes

You could create a new form bean copy the properties across from 
you  old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler 
that  using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna 
properties,  having a DynaProperty[] array and then use the 
dynaBean constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which 
can  not be decided at design time. I would like to populate the 
Business  data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties 
as  form-property. If i set  properties, without specifying them 
in the  struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name  
'statusChangeTime'
at  
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. 
java:598)
at  
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV 
iewBean(ObjectDetailsHandler.java:63)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje 
ctDetails(ObjectDetailsHandler.java:49)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob 
jectDetailsAction.java:54)

Please help me , in this regards,

Thanks in Advance.
With Regards,
R Balaji
-
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]





--
struts 1.1 + tomcat 4.1.27 + java 1.4.2
Linux 2.4.20 RH9
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: 

Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-24 Thread Mark Lowe
Okay .. I've been thinking about this.

I think it might work something like this..

form-property name=beans property=java.util.ArrayList /

The arrayList will be a container for your beans with indexed  
properties.

So in jsp we're thinking, or aiming for

logic:iterate id=bean name=myForm property=beans
bean:write name=bean property=key[%= index %] /
html:text name=bean property=value[%= index %]  /
/logic:iterate
So we have a bean thats mapped backed, or something here's some pseudo  
code.

public class MyBean {

	private Map map;

public Object[] getKeys() {
return map.keySet().toArray();
}

public Object[] getValues() {
ArrayList list = new ArrayList();
Object[] keys = getKeys();

for(int i = 0;i  keys.length;i++) {
String value = map.get(keys[i].toString());
list.add(value);
}

return list.toArray();
}
public String getKey(int i) {
return keys[i].toString();  
}

public String getValue(int i) {
String key = getKey(i);
return map.get(key);
}
public void setKey(int i, String str) {
keys[i] = str;
}
public void setValue(int i , String str) {
map.put(getKey(i),str);
}
...
well you get the idea..
Am I tree barking, smoking crack or something but Its starting look  
possible.. el should help move the scriptlets out, but using indexed,  
mapped properties looks like it may do the job.. the bean could have a  
double sided array it returns to keep the keys and values in the  
correct order. The keys are after all the illusion that the properties  
have names, when really they are associated via index. When it comes  
time to write to a db or something the bean could return a map and the  
key=value pairs should all be there ready.

Cheers mark

On Saturday, August 23, 2003, at 06:51 PM, Adam Hardy wrote:

I read your solution for populating the dynaform. How do you display  
it in JSP? I mean, how does the JSP know what the field names are?

I don't really know the internal workings of the dynavalidator form  
and how struts would populate the form bean with request parameters.  
You would probably have to do the same formbean initialization in the  
bean's reset method, otherwise the request parameters will probably  
not get saved to it.

Once you get that far, then validation becomes an issue. At design  
time you don't what the fields of a form will be - but do you know how  
any particular type of field should be validated? If so, how do you  
know? Is that in the design?

Adam

On 08/23/2003 05:34 PM R Balaji wrote:
Yes, Adam .. this is a valid point , that i need to consider.
But, it is almost impossible to define a bean for each type of data,  
in my application. I need to use the dynabean and dynaclass , some  
how.
I managed to find a solution for populating the bean ,  now i have to  
find a solution for validation too.
Suggest me  a suitable validation approach..
With Regards,
R Balaji
Adam Hardy wrote:
I can see that you could just iterate over the unknown form  
properties in the JSP, but how would you label them? And when the  
form is submitted, how would you validate them?

I think you would be better advised to add your list of properties  
as beans to your form. In each bean you could also have a label and  
a validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not  
sure  why you've a problem with just adding the fields to you form  
bean in  struts config. I've demonstrated how to literally do what  
you want, but  you'd have to specify the properties you want in you  
jsp anyway. But  here goes

You could create a new form bean copy the properties across from  
you  old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler  
that  using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna  
properties,  having a DynaProperty[] array and then use the  
dynaBean constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which  
can  not be decided at design time. I would like to populate the  
Business  data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties as  
 form-property. If i set  properties, without specifying them in  
the  struts-config.xml, i am getting 

Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-23 Thread Mark Lowe
You cant dynamically add properties to DynaActionForms. I'm not sure  
why you've a problem with just adding the fields to you form bean in  
struts config. I've demonstrated how to literally do what you want, but  
you'd have to specify the properties you want in you jsp anyway. But  
here goes

You could create a new form bean copy the properties across from you  
old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler that  
using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna properties,  
having a DynaProperty[] array and then use the dynaBean constructer  
that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which can  
not be decided at design time. I would like to populate the Business  
data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties as  
form-property. If i set  properties, without specifying them in the  
struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name  
'statusChangeTime'
	at  
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. 
java:598)
	at  
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412)
	at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV 
iewBean(ObjectDetailsHandler.java:63)
	at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje 
ctDetails(ObjectDetailsHandler.java:49)
	at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob 
jectDetailsAction.java:54)

Please help me , in this regards,

Thanks in Advance.
With Regards,
R Balaji
-
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: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-23 Thread Adam Hardy
I can see that you could just iterate over the unknown form properties 
in the JSP, but how would you label them? And when the form is 
submitted, how would you validate them?

I think you would be better advised to add your list of properties as 
beans to your form. In each bean you could also have a label and a 
validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:
You cant dynamically add properties to DynaActionForms. I'm not sure  
why you've a problem with just adding the fields to you form bean in  
struts config. I've demonstrated how to literally do what you want, but  
you'd have to specify the properties you want in you jsp anyway. But  
here goes

You could create a new form bean copy the properties across from you  
old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler that  
using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna properties,  
having a DynaProperty[] array and then use the dynaBean constructer  
that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which can  
not be decided at design time. I would like to populate the Business  
data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties as  
form-property. If i set  properties, without specifying them in the  
struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name  
'statusChangeTime'
at  
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. 
java:598)
at  
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV 
iewBean(ObjectDetailsHandler.java:63)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje 
ctDetails(ObjectDetailsHandler.java:49)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob 
jectDetailsAction.java:54)

Please help me , in this regards,

Thanks in Advance.
With Regards,
R Balaji
-
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]

--
struts 1.1 + tomcat 4.1.27 + java 1.4.2
Linux 2.4.20 RH9
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-23 Thread R Balaji
Hi Mark,

Thanks for your mail.
I tried your, our first suggestion, but the BeanUtils.populate(), wont 
go well with this dynamic properties. It throws

java.lang.NullPointerException at 
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:926) 
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808) 
at 
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.populateViewBean(ObjectDetailsAction.java:139) 

Actually, i am trying to display the properties of different 
ManagedResources. The will have different properties ( some may have 10, 
and others may have 30  properties, including few in this 10 ) ... so i 
can not pre-determine the properties, and specify them in the 
form-property tag.
Only while fetching and populating the bean , i will get to know the 
list of properties to be displayed in the UI. This stops me from 
modeling a bean for the view data.

Hope i m clear ...

I am jst trying your second approach .. do you have any code snippet for 
that ...

Thanks  regards,
R Balaji
Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not sure  
why you've a problem with just adding the fields to you form bean in  
struts config. I've demonstrated how to literally do what you want, 
but  you'd have to specify the properties you want in you jsp anyway. 
But  here goes

You could create a new form bean copy the properties across from you  
old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler that  
using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna 
properties,  having a DynaProperty[] array and then use the dynaBean 
constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which 
can  not be decided at design time. I would like to populate the 
Business  data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties as  
form-property. If i set  properties, without specifying them in 
the  struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name  
'statusChangeTime'
at  
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. 
java:598)
at  
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV 
iewBean(ObjectDetailsHandler.java:63)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje 
ctDetails(ObjectDetailsHandler.java:49)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob 
jectDetailsAction.java:54)

Please help me , in this regards,

Thanks in Advance.
With Regards,
R Balaji
-
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: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-23 Thread Mark Lowe
Okay

The code for creating a dynaBean etc is in the archieves when i messing  
around with dynaResultSet or whatever it was called.

Then try creating a form property form the key-value pairs..BeanUtils  
is just useful short-hand. But thats irrelevant now i know what you're  
trying to do.

You'll have an easier time by nesting beans as your form-property, and  
then i guess you beans will have to have a map or list style interface  
to pull generate your form.

Please any snippets are demonstration of concept, I could be very  
wrong.. but something like this. Using indexed properties should help  
you stop having to define dynaBeans on the fly, which last time i  
played with doing that things got very slow.

form-property name=resource type=java.util.ArrayList /
...
public class ManagedResourceBean {

private ArrayLIst list;

public ArrayList getList() {
return list;
}
getValue(int index) {
return list.get(index).toString();
}
setValue(String str) {
list.add(str);
}


}
..

ManagedResourceBean bean = new ManagedResourceBean();

iterator it = myResourcesFromMyModel.getResouces();

while(it.hasNext()) {
bean.setValue(it.next());   
}
theForm.set(resource,bean.getList());
..
logic:iterate id=item name=myForm property=resource
html:text name=item property=value[index] /
/logic:iterate
..

Some of the details are certainly wrong but I think the concept is okay.

Cheers Mark

On Saturday, August 23, 2003, at 12:22 PM, R Balaji wrote:

Hi Mark,

Thanks for your mail.
I tried your, our first suggestion, but the BeanUtils.populate(), wont  
go well with this dynamic properties. It throws

java.lang.NullPointerException at  
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:926)  
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)  
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.populateVi 
ewBean(ObjectDetailsAction.java:139)

Actually, i am trying to display the properties of different  
ManagedResources. The will have different properties ( some may have  
10, and others may have 30  properties, including few in this 10 ) ...  
so i can not pre-determine the properties, and specify them in the  
form-property tag.
Only while fetching and populating the bean , i will get to know the  
list of properties to be displayed in the UI. This stops me from  
modeling a bean for the view data.

Hope i m clear ...

I am jst trying your second approach .. do you have any code snippet  
for that ...

Thanks  regards,
R Balaji
Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not sure   
why you've a problem with just adding the fields to you form bean in   
struts config. I've demonstrated how to literally do what you want,  
but  you'd have to specify the properties you want in you jsp anyway.  
But  here goes

You could create a new form bean copy the properties across from you   
old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler that   
using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna  
properties,  having a DynaProperty[] array and then use the dynaBean  
constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which  
can  not be decided at design time. I would like to populate the  
Business  data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties as   
form-property. If i set  properties, without specifying them in  
the  struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name   
'statusChangeTime'
at   
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionFor 
m. java:598)
at   
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412)
at   
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populat 
eV iewBean(ObjectDetailsHandler.java:63)
at   
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchOb 
je ctDetails(ObjectDetailsHandler.java:49)
at   
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute( 
Ob jectDetailsAction.java:54)

Please help me , in this regards,

Thanks in Advance.
With Regards,
R Balaji
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To 

Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-23 Thread R Balaji
wow, thanks mark.

i managed to make the things working like this ,,,

   String className = viewBean.getDynaClass().getName();

   FormPropertyConfig propConfig = null;
   Enumeration keys = viewData.keys();
   while(keys.hasMoreElements())
   {
   String key=(String)keys.nextElement();
   String value = (String)viewData.getProperty(key);
   propConfig = new 
FormPropertyConfig(key,java.lang.String,value);
   config.addFormPropertyConfig(propConfig);
   } 
   DynaActionFormClass beanClass= 
DynaActionFormClass.createDynaActionFormClass(config);
 
   viewBean = (DynaValidatorForm) beanClass.newInstance(); 
  
   BeanUtils.populate(viewBean, viewData);

it is working fine now 

Regards,
b
 

Mark Lowe wrote:

Okay

The code for creating a dynaBean etc is in the archieves when i 
messing  around with dynaResultSet or whatever it was called.

Then try creating a form property form the key-value pairs..BeanUtils  
is just useful short-hand. But thats irrelevant now i know what 
you're  trying to do.

You'll have an easier time by nesting beans as your form-property, 
and  then i guess you beans will have to have a map or list style 
interface  to pull generate your form.

Please any snippets are demonstration of concept, I could be very  
wrong.. but something like this. Using indexed properties should help  
you stop having to define dynaBeans on the fly, which last time i  
played with doing that things got very slow.

form-property name=resource type=java.util.ArrayList /
...
public class ManagedResourceBean {

private ArrayLIst list;

public ArrayList getList() {
return list;
}

getValue(int index) {
return list.get(index).toString();
}
setValue(String str) {
list.add(str);
}


}

..

ManagedResourceBean bean = new ManagedResourceBean();

iterator it = myResourcesFromMyModel.getResouces();

while(it.hasNext()) {
bean.setValue(it.next());   
}

theForm.set(resource,bean.getList());
..
logic:iterate id=item name=myForm property=resource
html:text name=item property=value[index] /
/logic:iterate
..

Some of the details are certainly wrong but I think the concept is okay.

Cheers Mark

On Saturday, August 23, 2003, at 12:22 PM, R Balaji wrote:

Hi Mark,

Thanks for your mail.
I tried your, our first suggestion, but the BeanUtils.populate(), 
wont  go well with this dynamic properties. It throws

java.lang.NullPointerException at  
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:926)  
at 
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)  
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.populateVi 
ewBean(ObjectDetailsAction.java:139)

Actually, i am trying to display the properties of different  
ManagedResources. The will have different properties ( some may have  
10, and others may have 30  properties, including few in this 10 ) 
...  so i can not pre-determine the properties, and specify them in 
the  form-property tag.
Only while fetching and populating the bean , i will get to know the  
list of properties to be displayed in the UI. This stops me from  
modeling a bean for the view data.

Hope i m clear ...

I am jst trying your second approach .. do you have any code snippet  
for that ...

Thanks  regards,
R Balaji
Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not 
sure   why you've a problem with just adding the fields to you form 
bean in   struts config. I've demonstrated how to literally do what 
you want,  but  you'd have to specify the properties you want in you 
jsp anyway.  But  here goes

You could create a new form bean copy the properties across from 
you   old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler 
that   using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna  
properties,  having a DynaProperty[] array and then use the 
dynaBean  constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which  
can  not be decided at design time. I would like to populate the  
Business  data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties 
as   form-property. If i set  properties, without specifying them 
in  the  struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name   
'statusChangeTime'
at   
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionFor 
m. java:598)
at   

Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-23 Thread R Balaji
Yes, Adam .. this is a valid point , that i need to consider.

But, it is almost impossible to define a bean for each type of data, in 
my application. I need to use the dynabean and dynaclass , some how.

I managed to find a solution for populating the bean ,  now i have to 
find a solution for validation too.

Suggest me  a suitable validation approach..

With Regards,
R Balaji
Adam Hardy wrote:

I can see that you could just iterate over the unknown form properties 
in the JSP, but how would you label them? And when the form is 
submitted, how would you validate them?

I think you would be better advised to add your list of properties as 
beans to your form. In each bean you could also have a label and a 
validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not sure  
why you've a problem with just adding the fields to you form bean in  
struts config. I've demonstrated how to literally do what you want, 
but  you'd have to specify the properties you want in you jsp anyway. 
But  here goes

You could create a new form bean copy the properties across from you  
old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler that  
using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna 
properties,  having a DynaProperty[] array and then use the dynaBean 
constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which 
can  not be decided at design time. I would like to populate the 
Business  data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties as  
form-property. If i set  properties, without specifying them in 
the  struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name  
'statusChangeTime'
at  
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. 
java:598)
at  
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV 
iewBean(ObjectDetailsHandler.java:63)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje 
ctDetails(ObjectDetailsHandler.java:49)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob 
jectDetailsAction.java:54)

Please help me , in this regards,

Thanks in Advance.
With Regards,
R Balaji
-
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: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-23 Thread Mark Lowe
Nice..

Thats quite slick..

Also have you tried to submit the form yet? and print out its contents?  
I'd be interested to know..

Cheers Mark

On Saturday, August 23, 2003, at 04:29 PM, R Balaji wrote:

wow, thanks mark.

i managed to make the things working like this ,,,

   String className = viewBean.getDynaClass().getName();
   FormPropertyConfig propConfig = null;
   Enumeration keys = viewData.keys();
   while(keys.hasMoreElements())
   {
   String key=(String)keys.nextElement();
   String value = (String)viewData.getProperty(key);
   propConfig = new  
FormPropertyConfig(key,java.lang.String,value);
   config.addFormPropertyConfig(propConfig);
   }DynaActionFormClass beanClass=  
DynaActionFormClass.createDynaActionFormClass(config);
viewBean = (DynaValidatorForm)  
beanClass.newInstance();   
BeanUtils.populate(viewBean, viewData);

it is working fine now 

Regards,
b
Mark Lowe wrote:

Okay

The code for creating a dynaBean etc is in the archieves when i  
messing  around with dynaResultSet or whatever it was called.

Then try creating a form property form the key-value pairs..BeanUtils  
 is just useful short-hand. But thats irrelevant now i know what  
you're  trying to do.

You'll have an easier time by nesting beans as your form-property,  
and  then i guess you beans will have to have a map or list style  
interface  to pull generate your form.

Please any snippets are demonstration of concept, I could be very   
wrong.. but something like this. Using indexed properties should help  
 you stop having to define dynaBeans on the fly, which last time i   
played with doing that things got very slow.

form-property name=resource type=java.util.ArrayList /
...
public class ManagedResourceBean {
private ArrayLIst list;
public ArrayList getList() {
return list;
}
getValue(int index) {
return list.get(index).toString();
}
setValue(String str) {
list.add(str);
}
}
..

ManagedResourceBean bean = new ManagedResourceBean();

iterator it = myResourcesFromMyModel.getResouces();

while(it.hasNext()) {
bean.setValue(it.next());   }
theForm.set(resource,bean.getList());
..
logic:iterate id=item name=myForm property=resource
html:text name=item property=value[index] /
/logic:iterate
..

Some of the details are certainly wrong but I think the concept is  
okay.

Cheers Mark

On Saturday, August 23, 2003, at 12:22 PM, R Balaji wrote:

Hi Mark,

Thanks for your mail.
I tried your, our first suggestion, but the BeanUtils.populate(),  
wont  go well with this dynamic properties. It throws

java.lang.NullPointerException at   
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:926 
)  at  
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)   
at   
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.populate 
Vi ewBean(ObjectDetailsAction.java:139)

Actually, i am trying to display the properties of different   
ManagedResources. The will have different properties ( some may have  
 10, and others may have 30  properties, including few in this 10 )  
...  so i can not pre-determine the properties, and specify them in  
the  form-property tag.
Only while fetching and populating the bean , i will get to know the  
 list of properties to be displayed in the UI. This stops me from   
modeling a bean for the view data.

Hope i m clear ...

I am jst trying your second approach .. do you have any code snippet  
 for that ...

Thanks  regards,
R Balaji
Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not  
sure   why you've a problem with just adding the fields to you form  
bean in   struts config. I've demonstrated how to literally do what  
you want,  but  you'd have to specify the properties you want in  
you jsp anyway.  But  here goes

You could create a new form bean copy the properties across from  
you   old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler  
that   using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna   
properties,  having a DynaProperty[] array and then use the  
dynaBean  constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which   
can  not be decided at design time. I would like to populate the   
Business  data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties as  
  form-property. If i set  properties, without specifying them  
in  the  struts-config.xml, i 

Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-23 Thread R Balaji
yea, i just printed the details in the Ui. I looks great .. I will keep 
you posted if i get suceeded in submiting the form.

regards,
b
Mark Lowe wrote:

Nice..

Thats quite slick..

Also have you tried to submit the form yet? and print out its 
contents?  I'd be interested to know..

Cheers Mark

On Saturday, August 23, 2003, at 04:29 PM, R Balaji wrote:

wow, thanks mark.

i managed to make the things working like this ,,,

   String className = viewBean.getDynaClass().getName();
   FormPropertyConfig propConfig = null;
   Enumeration keys = viewData.keys();
   while(keys.hasMoreElements())
   {
   String key=(String)keys.nextElement();
   String value = (String)viewData.getProperty(key);
   propConfig = new  
FormPropertyConfig(key,java.lang.String,value);
   config.addFormPropertyConfig(propConfig);
   }DynaActionFormClass beanClass=  
DynaActionFormClass.createDynaActionFormClass(config);
viewBean = (DynaValidatorForm)  
beanClass.newInstance();   
BeanUtils.populate(viewBean, viewData);

it is working fine now 

Regards,
b
Mark Lowe wrote:

Okay

The code for creating a dynaBean etc is in the archieves when i  
messing  around with dynaResultSet or whatever it was called.

Then try creating a form property form the key-value 
pairs..BeanUtils   is just useful short-hand. But thats irrelevant 
now i know what  you're  trying to do.

You'll have an easier time by nesting beans as your form-property,  
and  then i guess you beans will have to have a map or list style  
interface  to pull generate your form.

Please any snippets are demonstration of concept, I could be very   
wrong.. but something like this. Using indexed properties should 
help   you stop having to define dynaBeans on the fly, which last 
time i   played with doing that things got very slow.

form-property name=resource type=java.util.ArrayList /
...
public class ManagedResourceBean {
private ArrayLIst list;
public ArrayList getList() {
return list;
}
getValue(int index) {
return list.get(index).toString();
}
setValue(String str) {
list.add(str);
}
}
..

ManagedResourceBean bean = new ManagedResourceBean();

iterator it = myResourcesFromMyModel.getResouces();

while(it.hasNext()) {
bean.setValue(it.next());   }
theForm.set(resource,bean.getList());
..
logic:iterate id=item name=myForm property=resource
html:text name=item property=value[index] /
/logic:iterate
..

Some of the details are certainly wrong but I think the concept is  
okay.

Cheers Mark

On Saturday, August 23, 2003, at 12:22 PM, R Balaji wrote:

Hi Mark,

Thanks for your mail.
I tried your, our first suggestion, but the BeanUtils.populate(),  
wont  go well with this dynamic properties. It throws

java.lang.NullPointerException at   
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:926 
)  at  
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)   
at   
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.populate 
Vi ewBean(ObjectDetailsAction.java:139)

Actually, i am trying to display the properties of different   
ManagedResources. The will have different properties ( some may 
have   10, and others may have 30  properties, including few in 
this 10 )  ...  so i can not pre-determine the properties, and 
specify them in  the  form-property tag.
Only while fetching and populating the bean , i will get to know 
the   list of properties to be displayed in the UI. This stops me 
from   modeling a bean for the view data.

Hope i m clear ...

I am jst trying your second approach .. do you have any code 
snippet   for that ...

Thanks  regards,
R Balaji
Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not  
sure   why you've a problem with just adding the fields to you 
form  bean in   struts config. I've demonstrated how to literally 
do what  you want,  but  you'd have to specify the properties you 
want in  you jsp anyway.  But  here goes

You could create a new form bean copy the properties across from  
you   old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler  
that   using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna   
properties,  having a DynaProperty[] array and then use the  
dynaBean  constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, 
which   can  not be decided at design time. I would like to 
populate the   Business  data into a dynaValidatorForm and 
display them.

In this 

Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-23 Thread Adam Hardy
I read your solution for populating the dynaform. How do you display it 
in JSP? I mean, how does the JSP know what the field names are?

I don't really know the internal workings of the dynavalidator form and 
how struts would populate the form bean with request parameters. You 
would probably have to do the same formbean initialization in the bean's 
reset method, otherwise the request parameters will probably not get 
saved to it.

Once you get that far, then validation becomes an issue. At design time 
you don't what the fields of a form will be - but do you know how any 
particular type of field should be validated? If so, how do you know? Is 
that in the design?

Adam

On 08/23/2003 05:34 PM R Balaji wrote:
Yes, Adam .. this is a valid point , that i need to consider.

But, it is almost impossible to define a bean for each type of data, in 
my application. I need to use the dynabean and dynaclass , some how.

I managed to find a solution for populating the bean ,  now i have to 
find a solution for validation too.

Suggest me  a suitable validation approach..

With Regards,
R Balaji
Adam Hardy wrote:

I can see that you could just iterate over the unknown form properties 
in the JSP, but how would you label them? And when the form is 
submitted, how would you validate them?

I think you would be better advised to add your list of properties as 
beans to your form. In each bean you could also have a label and a 
validation.

my 2 cents.
Adam


On 08/23/2003 12:03 PM Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not sure  
why you've a problem with just adding the fields to you form bean in  
struts config. I've demonstrated how to literally do what you want, 
but  you'd have to specify the properties you want in you jsp anyway. 
But  here goes

You could create a new form bean copy the properties across from you  
old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler that  
using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna 
properties,  having a DynaProperty[] array and then use the dynaBean 
constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which 
can  not be decided at design time. I would like to populate the 
Business  data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties as  
form-property. If i set  properties, without specifying them in 
the  struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name  
'statusChangeTime'
at  
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm. 
java:598)
at  
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateV 
iewBean(ObjectDetailsHandler.java:63)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObje 
ctDetails(ObjectDetailsHandler.java:49)
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(Ob 
jectDetailsAction.java:54)

Please help me , in this regards,

Thanks in Advance.
With Regards,
R Balaji
-
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]



--
struts 1.1 + tomcat 4.1.27 + java 1.4.2
Linux 2.4.20 RH9
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-23 Thread Mark Lowe
I've made an obvious error in that you want an arrayList of beans with  
indexed props being stamped-out in your page.

in your action

ArrayList beanList = new ArrayLIst();

beanList.add(bean);

theForm.set(resource,beanList);

On Saturday, August 23, 2003, at 04:01 PM, Mark Lowe wrote:

Okay

The code for creating a dynaBean etc is in the archieves when i  
messing around with dynaResultSet or whatever it was called.

Then try creating a form property form the key-value pairs..BeanUtils  
is just useful short-hand. But thats irrelevant now i know what you're  
trying to do.

You'll have an easier time by nesting beans as your form-property, and  
then i guess you beans will have to have a map or list style interface  
to pull generate your form.

Please any snippets are demonstration of concept, I could be very  
wrong.. but something like this. Using indexed properties should help  
you stop having to define dynaBeans on the fly, which last time i  
played with doing that things got very slow.

form-property name=resource type=java.util.ArrayList /
...
public class ManagedResourceBean {

private ArrayLIst list;

public ArrayList getList() {
return list;
}
getValue(int index) {
return list.get(index).toString();
}
setValue(String str) {
list.add(str);
}


}
..

ManagedResourceBean bean = new ManagedResourceBean();

iterator it = myResourcesFromMyModel.getResouces();

while(it.hasNext()) {
bean.setValue(it.next());   
}
theForm.set(resource,bean.getList());
..
logic:iterate id=item name=myForm property=resource
html:text name=item property=value[index] /
/logic:iterate
..

Some of the details are certainly wrong but I think the concept is  
okay.

Cheers Mark

On Saturday, August 23, 2003, at 12:22 PM, R Balaji wrote:

Hi Mark,

Thanks for your mail.
I tried your, our first suggestion, but the BeanUtils.populate(),  
wont go well with this dynamic properties. It throws

java.lang.NullPointerException at  
org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:926) 
 at  
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)  
at  
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.populateV 
iewBean(ObjectDetailsAction.java:139)

Actually, i am trying to display the properties of different  
ManagedResources. The will have different properties ( some may have  
10, and others may have 30  properties, including few in this 10 )  
... so i can not pre-determine the properties, and specify them in  
the form-property tag.
Only while fetching and populating the bean , i will get to know the  
list of properties to be displayed in the UI. This stops me from  
modeling a bean for the view data.

Hope i m clear ...

I am jst trying your second approach .. do you have any code snippet  
for that ...

Thanks  regards,
R Balaji
Mark Lowe wrote:

You cant dynamically add properties to DynaActionForms. I'm not sure  
 why you've a problem with just adding the fields to you form bean  
in  struts config. I've demonstrated how to literally do what you  
want, but  you'd have to specify the properties you want in you jsp  
anyway. But  here goes

You could create a new form bean copy the properties across from you  
 old one and then add some new stuff..

DynaActionForm oldForm = (DynaActionForm) form;

//get the map out and mess with this and life should be simpler that  
 using the dynaBean
Map oldFormMap = oldForm.getMap();

oldFormMap.put(statusChangeTime,A new Time);

DynaActionForm newForm = new DynaActionForm();

BeanUtils.populate(newForm, oldFormMap);

If this doesn't work you can try constructing all you dyna  
properties,  having a DynaProperty[] array and then use the dynaBean  
constructer  that takes a properties array.

Cheers Mark

On Saturday, August 23, 2003, at 04:42 AM, R Balaji wrote:

Dear All,
I have an application which returns a varity of properties, which  
can  not be decided at design time. I would like to populate the  
Business  data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties as   
form-property. If i set  properties, without specifying them in  
the  struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name   
'statusChangeTime'
at   
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionFo 
rm. java:598)
at   
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412)
at   
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.popula 
teV iewBean(ObjectDetailsHandler.java:63)
at   
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchO 
bje ctDetails(ObjectDetailsHandler.java:49)
at   
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute 
(Ob jectDetailsAction.java:54)

Please help me , in 

How to dynamically decide the properties of the DynaValidator/DynaActionForm

2003-08-22 Thread R Balaji
Dear All,
I have an application which returns a varity of properties, which can 
not be decided at design time. I would like to populate the Business 
data into a dynaValidatorForm and display them.

In this case, it is not possible to  specify all the properties as 
form-property. If i set  properties, without specifying them in the 
struts-config.xml, i am getting exception as mentioned below.

java.lang.IllegalArgumentException: Invalid property name 'statusChangeTime'
	at 
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm.java:598)
	at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:412)
	at 
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.populateViewBean(ObjectDetailsHandler.java:63)
	at 
com.adventnet.nms.webclient.topo.details.ObjectDetailsHandler.fetchObjectDetails(ObjectDetailsHandler.java:49)
	at 
com.adventnet.nms.webclient.topo.details.ObjectDetailsAction.execute(ObjectDetailsAction.java:54)

Please help me , in this regards,

Thanks in Advance.
With Regards,
R Balaji
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]