How to avoid contribution to TypeCoercer in my case.

View: New views
5 Messages — Rating Filter:   Alert me  

How to avoid contribution to TypeCoercer in my case.

by sandeepraj singh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,
I have the following

In MyComponent.tml
<t:loop source="mYlist" value="prop:MyDataObject">
 
//Code below is not being seen on the post for some reason so, am writing it in words.
//Action tag with a context of such kind t:context="prop:MyDataObject.somevariable"
"${MyDataObject.someothervariable}"
 
</t:loop>

Ofcourse there is supporting code for the same in MyComponent.java. ie. having an istance variable of MyDataObject etc.

In my Page, there are 2 cases
1) I use the component without an enclosing form. In this case the component works abs fine.
2) I use the component with an enclosing form. In such a case ,i recieve co-ercion error because of the context value that is being passed and is mapped to MyDataObject. The error is recieved only when the Enclosing FORM IS SUBMITTED.

For scenario 2, i make a contribution to TypeCoercer to force creation of MyDataObject so that the problem is solved. But can any one think of a better way. A way in which some code in My Component takes care of the problem rather than a contribution inthe service.

Thanks
sandeep

Re: How to avoid contribution to TypeCoercer in my case.

by Niclas.Meier :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi sandeep,

The effekt that occurs is, that tapestry tries to provide a loop
context/state for the enclosing form. You need this if you have any fields
in your loop.

If you don¹t want/need to provide a context you may mark the loop as
voliatile. This looks like:

<t:loop source="mYlist" value="prop:MyDataObject" volatile=²true²> ...
</t:loop>
 
Otherwise you'll have to provide a form state. I guess it would look like

<t:loop source="mYlist" value="prop:MyDataObject"
volatile=²MyDataObject.someID²> ... </t:loop>

The tapestry error message in this case is - IMHO - improvable ;-)

Regards
Niclas


On 30.10.09 08:31, "sandeepraj singh" <sandeepraj.singh@...>
wrote:

>
>
> Hi All,
> I have the following
>
> In MyComponent.tml
> <t:loop source="mYlist" value="prop:MyDataObject">
>        
>          ${MyDataObject.someothervariable} </li>
>                
> </t:loop>
>
> Ofcourse there is supporting code for the same in MyComponent.java. ie.
> having an istance variable of MyDataObject etc.
>
> In my Page, there are 2 cases
> 1) I use the component without an enclosing form. In this case the component
> works abs fine.
> 2) I use the component with an enclosing form. In such a case ,i recieve
> co-ercion error because of the context value that is being passed and is
> mapped to MyDataObject. The error is recieved only when the Enclosing FORM
> IS SUBMITTED.
>
> For scenario 2, i make a contribution to TypeCoercer to force creation of
> MyDataObject so that the problem is solved. But can any one think of a
> better way. A way in which some code in My Component takes care of the
> problem rather than a contribution inthe service.
>
> Thanks
> sandeep
> --
> View this message in context:
> http://old.nabble.com/How-to-avoid-contribution-to-TypeCoercer-in-my-case.-tp2
> 6126002p26126002.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: How to avoid contribution to TypeCoercer in my case.

by sandeepraj singh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Niclas,
Sorry for a delayed response.
The solution you suggest is not working.
My Original Code is like below

<t:loop source="mYlist" value="prop:MyDataObject" > ...
  <p t:type=eventlink" t:context=prop:MyDataObject.myContent>myDataObject.myOtherContent</p>
</t:loop>

As per your suggestion i changed it to
<t:loop source="mYlist" value="prop:MyDataObject"  volatile=MyDataObject.myContent> ...
  <p t:type="eventlink" t:context=prop:MyDataObject.myContent>myDataObject.myOtherContent</p>
</t:loop>

also tried with values of Volatile = "true" etc
It still asks for co-ercion of String to MyDataObject

Would be grateful for any further pointers

Thanks
Sandeep

Niclas.Meier wrote:
Hi sandeep,

The effekt that occurs is, that tapestry tries to provide a loop
context/state for the enclosing form. You need this if you have any fields
in your loop.

If you don¹t want/need to provide a context you may mark the loop as
voliatile. This looks like:

<t:loop source="mYlist" value="prop:MyDataObject" volatile=²true²> ...
</t:loop>
 
Otherwise you'll have to provide a form state. I guess it would look like

<t:loop source="mYlist" value="prop:MyDataObject"
volatile=²MyDataObject.someID²> ... </t:loop>

The tapestry error message in this case is - IMHO - improvable ;-)

Regards
Niclas


On 30.10.09 08:31, "sandeepraj singh" <sandeepraj.singh@atosorigin.com>
wrote:

>
>
> Hi All,
> I have the following
>
> In MyComponent.tml
> <t:loop source="mYlist" value="prop:MyDataObject">
>        
>          ${MyDataObject.someothervariable} </li>
>                
> </t:loop>
>
> Ofcourse there is supporting code for the same in MyComponent.java. ie.
> having an istance variable of MyDataObject etc.
>
> In my Page, there are 2 cases
> 1) I use the component without an enclosing form. In this case the component
> works abs fine.
> 2) I use the component with an enclosing form. In such a case ,i recieve
> co-ercion error because of the context value that is being passed and is
> mapped to MyDataObject. The error is recieved only when the Enclosing FORM
> IS SUBMITTED.
>
> For scenario 2, i make a contribution to TypeCoercer to force creation of
> MyDataObject so that the problem is solved. But can any one think of a
> better way. A way in which some code in My Component takes care of the
> problem rather than a contribution inthe service.
>
> Thanks
> sandeep
> --
> View this message in context:
> http://old.nabble.com/How-to-avoid-contribution-to-TypeCoercer-in-my-case.-tp2
> 6126002p26126002.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org

Re: How to avoid contribution to TypeCoercer in my case.

by Inge Solvoll-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I struggled a lot with loops in forms, I still do to tell you the truth. See
this page in jumpstart, it helped me a lot. If you use
formstate="ITERATION", it won't ask you for a coercer. Formstate and loops
is one of the harder concepts of T5 in my opinion, it doesn't seem logical
to me so I don't understand what to do.

http://202.177.217.122:8080/jumpstart/examples/tables/editableloop1



On Tue, Nov 10, 2009 at 7:47 AM, sandeepraj singh <
sandeepraj.singh@...> wrote:

>
> Hi Niclas,
> Sorry for a delayed response.
> The solution you suggest is not working.
> My Original Code is like below
>
> <t:loop source="mYlist" value="prop:MyDataObject" > ...
> myDataObject.myOtherContent
> </t:loop>
>
> As per your suggestion i changed it to
> <t:loop source="mYlist" value="prop:MyDataObject"
> volatile=MyDataObject.myContent> ...
> myDataObject.myOtherContent
> </t:loop>
>
> also tried with values of Volatile = "true" etc
> It still asks for co-ercion of String to MyDataObject
>
> Would be grateful for any further pointers
>
> Thanks
> Sandeep
>
>
> Niclas.Meier wrote:
> >
> > Hi sandeep,
> >
> > The effekt that occurs is, that tapestry tries to provide a loop
> > context/state for the enclosing form. You need this if you have any
> fields
> > in your loop.
> >
> > If you don¹t want/need to provide a context you may mark the loop as
> > voliatile. This looks like:
> >
> > <t:loop source="mYlist" value="prop:MyDataObject" volatile=²true²> ...
> > </t:loop>
> >
> > Otherwise you'll have to provide a form state. I guess it would look like
> >
> > <t:loop source="mYlist" value="prop:MyDataObject"
> > volatile=²MyDataObject.someID²> ... </t:loop>
> >
> > The tapestry error message in this case is - IMHO - improvable ;-)
> >
> > Regards
> > Niclas
> >
> >
> > On 30.10.09 08:31, "sandeepraj singh" <sandeepraj.singh@...>
> > wrote:
> >
> >>
> >>
> >> Hi All,
> >> I have the following
> >>
> >> In MyComponent.tml
> >> <t:loop source="mYlist" value="prop:MyDataObject">
> >>
> >>          ${MyDataObject.someothervariable} </li>
> >>
> >> </t:loop>
> >>
> >> Ofcourse there is supporting code for the same in MyComponent.java. ie.
> >> having an istance variable of MyDataObject etc.
> >>
> >> In my Page, there are 2 cases
> >> 1) I use the component without an enclosing form. In this case the
> >> component
> >> works abs fine.
> >> 2) I use the component with an enclosing form. In such a case ,i recieve
> >> co-ercion error because of the context value that is being passed and is
> >> mapped to MyDataObject. The error is recieved only when the Enclosing
> >> FORM
> >> IS SUBMITTED.
> >>
> >> For scenario 2, i make a contribution to TypeCoercer to force creation
> of
> >> MyDataObject so that the problem is solved. But can any one think of a
> >> better way. A way in which some code in My Component takes care of the
> >> problem rather than a contribution inthe service.
> >>
> >> Thanks
> >> sandeep
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/How-to-avoid-contribution-to-TypeCoercer-in-my-case.-tp2
> >> 6126002p26126002.html
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@...
> >> For additional commands, e-mail: users-help@...
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/How-to-avoid-contribution-to-TypeCoercer-in-my-case.-tp26126002p26279024.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

Re: How to avoid contribution to TypeCoercer in my case.

by sandeepraj singh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Inge

The solution you provide works fine.
But to a lesser mortal like me, the description of ITERATION in LoopFormState is a bit difficult
/**
  * Only enough state to iterate over the source values is stored. When the Form is submitted,
the Loop will  re-acquire its source and iterate over it. This is equivalent to "volatile" mode in Tapestry 5.0. This can be subject to race conditions when the values within the source change between render and submit.*/

From above its ok to guess what it is doing, but how is it solving the co-ercion problem

Any discussions?

Thanks
Sandeep

Inge Solvoll-2 wrote:
I struggled a lot with loops in forms, I still do to tell you the truth. See
this page in jumpstart, it helped me a lot. If you use
formstate="ITERATION", it won't ask you for a coercer. Formstate and loops
is one of the harder concepts of T5 in my opinion, it doesn't seem logical
to me so I don't understand what to do.

http://202.177.217.122:8080/jumpstart/examples/tables/editableloop1



On Tue, Nov 10, 2009 at 7:47 AM, sandeepraj singh <
sandeepraj.singh@atosorigin.com> wrote:

>
> Hi Niclas,
> Sorry for a delayed response.
> The solution you suggest is not working.
> My Original Code is like below
>
> <t:loop source="mYlist" value="prop:MyDataObject" > ...
> myDataObject.myOtherContent
> </t:loop>
>
> As per your suggestion i changed it to
> <t:loop source="mYlist" value="prop:MyDataObject"
> volatile=MyDataObject.myContent> ...
> myDataObject.myOtherContent
> </t:loop>
>
> also tried with values of Volatile = "true" etc
> It still asks for co-ercion of String to MyDataObject
>
> Would be grateful for any further pointers
>
> Thanks
> Sandeep
>
>
> Niclas.Meier wrote:
> >
> > Hi sandeep,
> >
> > The effekt that occurs is, that tapestry tries to provide a loop
> > context/state for the enclosing form. You need this if you have any
> fields
> > in your loop.
> >
> > If you don¹t want/need to provide a context you may mark the loop as
> > voliatile. This looks like:
> >
> > <t:loop source="mYlist" value="prop:MyDataObject" volatile=²true²> ...
> > </t:loop>
> >
> > Otherwise you'll have to provide a form state. I guess it would look like
> >
> > <t:loop source="mYlist" value="prop:MyDataObject"
> > volatile=²MyDataObject.someID²> ... </t:loop>
> >
> > The tapestry error message in this case is - IMHO - improvable ;-)
> >
> > Regards
> > Niclas
> >
> >
> > On 30.10.09 08:31, "sandeepraj singh" <sandeepraj.singh@atosorigin.com>
> > wrote:
> >
> >>
> >>
> >> Hi All,
> >> I have the following
> >>
> >> In MyComponent.tml
> >> <t:loop source="mYlist" value="prop:MyDataObject">
> >>
> >>          ${MyDataObject.someothervariable} </li>
> >>
> >> </t:loop>
> >>
> >> Ofcourse there is supporting code for the same in MyComponent.java. ie.
> >> having an istance variable of MyDataObject etc.
> >>
> >> In my Page, there are 2 cases
> >> 1) I use the component without an enclosing form. In this case the
> >> component
> >> works abs fine.
> >> 2) I use the component with an enclosing form. In such a case ,i recieve
> >> co-ercion error because of the context value that is being passed and is
> >> mapped to MyDataObject. The error is recieved only when the Enclosing
> >> FORM
> >> IS SUBMITTED.
> >>
> >> For scenario 2, i make a contribution to TypeCoercer to force creation
> of
> >> MyDataObject so that the problem is solved. But can any one think of a
> >> better way. A way in which some code in My Component takes care of the
> >> problem rather than a contribution inthe service.
> >>
> >> Thanks
> >> sandeep
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/How-to-avoid-contribution-to-TypeCoercer-in-my-case.-tp2
> >> 6126002p26126002.html
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/How-to-avoid-contribution-to-TypeCoercer-in-my-case.-tp26126002p26279024.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>