[s2] Making LazyDynaBean work with ModelDriven interface

2006-12-05 Thread Mark Shifman
Some folks may be as pig-headed as me or may need to use LazyDynaBeans 
as they are translating
from struts1 to struts2.  After fooling around, I figured it out but it 
is pretty clear to me this is not the way to go.

Below is a simple example.

public final class MyAction extends ActionSupport implements ModelDriven{

   private LazyDynaBean f = new LazyDynaBean();
   public String execute() throws Exception  {
  
   String[] text_field = (String[])f.get(text_field);
   //do something with the text_field that came from LazyDynaBean 
as a String array

  return SUCCESS;
   }
  
  public Object getModel(){

   return f;
   }
}

s:form action=MyAction
   s:textfield name=map.text_field /
   s:submit /
/s:form

validators
   field name=map.text_field
   field-validator type=required
   messageText Field is required./message
   /field-validator
   /field
/validators

There were 2 things that bit me:
1.  You have to get the field name  from map.text field so that 
s:textfield can get it from the map on the valuestack and
2.  The textfield seems to get a String[] rather than a String and I 
don't have any idea how to do it differently.


mas



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [s2] Making LazyDynaBean work with ModelDriven interface

2006-12-05 Thread Mark Menard
On 12/5/06 12:25 PM, Mark Shifman [EMAIL PROTECTED] wrote:
 2.  The textfield seems to get a String[] rather than a String and I
 don't have any idea how to do it differently.

I donĀ¹t know if you can do this because I've never really worked with Struts
1. Can you make the Map in your form a MapObject,String? That might make
the values be String instead of String[]. This is only an idea.

I'm not sure OGNL will do this with generics. You could test it easily
enough by making your model just a MapObject,String and see if that works.

Mark

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]