You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Vjeran Marcinko <vj...@email.t-com.hr> on 2009/07/24 08:11:09 UTC

Please don't tell me this is impossible in T5

Hello,

I almost converted my old T4 web app to T5, but stumbled upon one major 
problem and I cannot find any help in mail list archive...

I'm using one page to edit whole class hierarchy (ie., multiple subclasses 
of one superclass), and instantiation of specific subclass happens in 
"onPrepare" method as typical based on some page activation context value.
My field inside my page is defined as superclass becase this page handles 
whole hierarchy:

public MyEditPage {
....
@Property
private MySuperclass mySuperclass;

private void onPrepare() {
    mySuperclass = (some condition) ? new Subclass1() : new Subclass2();
}

In template I have one textfield which is bound to property that is 
contained only inside Subclass1, but since Tapestry introspects page at the 
beggining searching for some invalid properties, and it cannot find this 
property inside superclass, it raises exception saying it cannot find this 
property!!! :-(

<t:texfield t:value="mySuperclass.someSubclass1Property"/>

I really hope that this thing is not impossible to do in T5..

-Vjeran 


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


Re: Please don't tell me this is impossible in T5

Posted by Robert Zeigler <ro...@scazdl.org>.
Hm... if it's an isolated case, it's simple enough to work around.
You could:

.java:
   public Subclass1 getSuperAsSub() {
       return (Subclass1) mySuperclass;
   }
.tml:
   <t:textfield value="superAsSub.someProperty"/>

Or you could:

.java:
   public Object getProp() { return  
((Subclass1)mySuperclass).getProp(); }
   public void setProp(Object val)  
{ ((Subclass1)mySuperclass).setProp(val); }
.tml
   <t:textfield value="prop"/>

Or you could always revert to using ognl for those properties; you  
lose the performance benefits of prop, but also the "compile-time"  
restrictions are loosened (chenillekit provides an ognl binding).

Or you could write a custom binding.

:)

Robert

On Jul 24, 2009, at 7/241:11 AM , Vjeran Marcinko wrote:

> Hello,
>
> I almost converted my old T4 web app to T5, but stumbled upon one  
> major problem and I cannot find any help in mail list archive...
>
> I'm using one page to edit whole class hierarchy (ie., multiple  
> subclasses of one superclass), and instantiation of specific  
> subclass happens in "onPrepare" method as typical based on some page  
> activation context value.
> My field inside my page is defined as superclass becase this page  
> handles whole hierarchy:
>
> public MyEditPage {
> ....
> @Property
> private MySuperclass mySuperclass;
>
> private void onPrepare() {
>   mySuperclass = (some condition) ? new Subclass1() : new Subclass2();
> }
>
> In template I have one textfield which is bound to property that is  
> contained only inside Subclass1, but since Tapestry introspects page  
> at the beggining searching for some invalid properties, and it  
> cannot find this property inside superclass, it raises exception  
> saying it cannot find this property!!! :-(
>
> <t:texfield t:value="mySuperclass.someSubclass1Property"/>
>
> I really hope that this thing is not impossible to do in T5..
>
> -Vjeran
>
> ---------------------------------------------------------------------
> 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