You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nandana Mihindukulasooriya <na...@gmail.com> on 2008/03/11 12:03:50 UTC

[s2] Question about Advanced Type Conversion/Collection and Map Support

Hi,
   I want to use type conversion  feature to convert set of values to
a list in my action as mentioned in the type conversion documentation
(Advanced Type Conversion/Collection and Map Support) [1]. I followed
the steps but still no luck. I have few questions. (please excuse if
these questions are too naive , I am new to Structs 2).

i)   Where should I put MyBeanAction-conversion.properties file ?
ii)  Using the debug mode, can I check whether the
ObjectTypeDeterminer picked it ?
iii) Can I find sample application which which uses this feature
somewhere online ?

thanks,
nandana

[1] - http://struts.apache.org/2.x/docs/type-conversion.html

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


Re: [s2] Question about Advanced Type Conversion/Collection and Map Support

Posted by Nandana Mihindukulasooriya <na...@gmail.com>.
Hi Jeromy,

Thanks a lot for your guidance. I was able to get it working with your
information. And the that demo site you send was very helpful too.

thanks,
/nandana

On Tue, Mar 11, 2008 at 7:01 PM, Jeromy Evans
<je...@blueskyminds.com.au> wrote:
> Nandana Mihindukulasooriya wrote:
>  > Hi,
>  >    I want to use type conversion  feature to convert set of values to
>  > a list in my action as mentioned in the type conversion documentation
>  > (Advanced Type Conversion/Collection and Map Support) [1]. I followed
>  > the steps but still no luck. I have few questions. (please excuse if
>  > these questions are too naive , I am new to Structs 2).
>  >
>  > i)   Where should I put MyBeanAction-conversion.properties file ?
>  >
>
>  In the same directory as MyBeanAction.java
>
>
>  > ii)  Using the debug mode, can I check whether the
>  > ObjectTypeDeterminer picked it ?
>  >
>
>  Yes, download the source code for Struts and XWork and you can trace
>  through it.  I don't recall it displaying any useful debug messages in
>  the log.
>
>  I find this type "advanced" conversion very frustrating every time I
>  attempt to use it.  Just try to keep it simple.
>  I always either use:
>   a Map, and reference each entry by its key (which is a string).  eg
>  field['a'].value; or
>   a List, and reference each try by its index eg. field[0].value; and
>   make each entry a simple bean that doesn't require non-standard conversion
>
>  Finally ensure you have getters for the collections so OGNL can get it
>  before writing to it, and ensure it's a non-abstract type or instantiate
>  it yourself before the entries are set on it.
>
>  Also turn on devMode for your application.
>
>  Hope that helps.
>
>  Examples: http://www.planetstruts.org/struts2-showcase/conversion/index.jsp
>
>  >
>  >
>  >
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>  For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: [s2] Question about Advanced Type Conversion/Collection and Map Support

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Nandana Mihindukulasooriya wrote:
> Hi,
>    I want to use type conversion  feature to convert set of values to
> a list in my action as mentioned in the type conversion documentation
> (Advanced Type Conversion/Collection and Map Support) [1]. I followed
> the steps but still no luck. I have few questions. (please excuse if
> these questions are too naive , I am new to Structs 2).
>
> i)   Where should I put MyBeanAction-conversion.properties file ?
>   

In the same directory as MyBeanAction.java

> ii)  Using the debug mode, can I check whether the
> ObjectTypeDeterminer picked it ?
>   

Yes, download the source code for Struts and XWork and you can trace 
through it.  I don't recall it displaying any useful debug messages in 
the log.

I find this type "advanced" conversion very frustrating every time I 
attempt to use it.  Just try to keep it simple.
I always either use:
  a Map, and reference each entry by its key (which is a string).  eg 
field['a'].value; or
  a List, and reference each try by its index eg. field[0].value; and
  make each entry a simple bean that doesn't require non-standard conversion
 
Finally ensure you have getters for the collections so OGNL can get it 
before writing to it, and ensure it's a non-abstract type or instantiate 
it yourself before the entries are set on it.

Also turn on devMode for your application.

Hope that helps.

Examples: http://www.planetstruts.org/struts2-showcase/conversion/index.jsp

>
>
>   


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