You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Robert A. Decker" <de...@robdecker.com> on 2007/10/05 01:00:46 UTC

coercion error?

I'm getting an error:
"Could not find a coercion from type com.pgp.licenseserver.pages.Main  
to type com.pgp.licenseserver.pages._PGPLicenseServerPage. Available  
coercions:..."

But my Main.java extends _PGPLicenseServerPage and so there shouldn't  
be any coercion necessary.

And besides, why should it care what the type is? Can't it just send  
it the message I'm trying to send and not care about the type?


I'm trying to add to the layout example component to give menu-item  
links at the top of the page and if we're in a particular section of  
the app have that link not be active, but the other links be active.  
I do this by having the pages that belong in each section implement  
an interface for that section. For example, my 'Main' page has its  
own section:

public class Main extends _PGPLicenseServerPage implements  
_MainSection {...}

And in my superclass:
public class _PGPLicenseServerPage {
	public boolean isMainSection() {
		return this instanceof _MainSection;
	}
}

And so in my Layout.html I would like to do something like:
									<t:if test="parent.isMainSection">
								          main
								    </t:if>
									<t:else>
										<a href="#">main</a>
									</t:else>
(I don't think this is right - I haven't been able to find an example  
of an if/else)


I've tried messing around with different ways of calling things but I  
keep getting various exceptions... Any way to get this to work? I do  
something like this all of the time in WebObjects and it's quite easy.

R

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


Re: coercion error?

Posted by Nick Westgate <ni...@key-planning.co.jp>.
Note there are cleaner ways of writing the HTML. The "Tapestry Way"
is to to get components to do the work for you.

You could use your own link component or an Action or (*)PageLink:

<a t:type="YourLink" t:id="mainLink" t:disabled="parent.isMainSection" href="#">main</a>

(*) This will work for ActionLink, but PageLink currently doesn't
support "disabled". (There is already a JIRA issue and patch.)
https://issues.apache.org/jira/browse/TAPESTRY-1735

It's easy enough to create your own PageLink which fixes this.

Cheers,
Nick.


Josh Canfield wrote:
> HI Robert,
> 
> An if/else looks like this:
> 
> <t:if test="isMainSection"> <!-- no need for ${} in tapestry components -->
> The if stuff
> <t:parameter name="else">
> the else stuff
> </t:parameter>
> </t:if>
> 
> 
> Josh
> 
> 
> On 10/4/07, Robert A. Decker <rd...@pgp.com> wrote:
>> I kind of got around this by putting in my Layout.html:
>>
>> <t:if test="${isMainSection}">
>>
>> main
>>
>> </t:if>
>>
>> And in Layout.java:
>>        public boolean getIsMainSection() {
>>                return _parent.isMainSection();
>>        }
>>
>>
>> It's not ideal - it'd be better to be able to ask the _parent
>> directly rather than going through Layout.java, but this works for
>> now, until I learn Tapestry well enough to fix it up.
>>
>> Now I just need to figure out how to do the else...
>>
>> R
>>
>>
>> On Oct 4, 2007, at 4:00 PM, Robert A. Decker wrote:
>>
>>> I'm getting an error:
>>> "Could not find a coercion from type
>>> com.pgp.licenseserver.pages.Main to type
>>> com.pgp.licenseserver.pages._PGPLicenseServerPage. Available
>>> coercions:..."
>>>
>>> But my Main.java extends _PGPLicenseServerPage and so there
>>> shouldn't be any coercion necessary.
>>>
>>> And besides, why should it care what the type is? Can't it just
>>> send it the message I'm trying to send and not care about the type?
>>>
>>>
>>> I'm trying to add to the layout example component to give menu-item
>>> links at the top of the page and if we're in a particular section
>>> of the app have that link not be active, but the other links be
>>> active. I do this by having the pages that belong in each section
>>> implement an interface for that section. For example, my 'Main'
>>> page has its own section:
>>>
>>> public class Main extends _PGPLicenseServerPage implements
>>> _MainSection {...}
>>>
>>> And in my superclass:
>>> public class _PGPLicenseServerPage {
>>>       public boolean isMainSection() {
>>>               return this instanceof _MainSection;
>>>       }
>>> }
>>>
>>> And so in my Layout.html I would like to do something like:
>>>
>> <t:if test="parent.isMainSection">
>> main
>> </t:if>
>> <t:else>
>> <a href="#">main</a>
>> </t:else>
>>> (I don't think this is right - I haven't been able to find an
>>> example of an if/else)
>>>
>>>
>>> I've tried messing around with different ways of calling things but
>>> I keep getting various exceptions... Any way to get this to work? I
>>> do something like this all of the time in WebObjects and it's quite
>>> easy.
>>>
>>> R
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
> 
> 

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


Re: coercion error?

Posted by Josh Canfield <jo...@thedailytube.com>.
HI Robert,

An if/else looks like this:

<t:if test="isMainSection"> <!-- no need for ${} in tapestry components -->
The if stuff
<t:parameter name="else">
the else stuff
</t:parameter>
</t:if>


Josh


On 10/4/07, Robert A. Decker <rd...@pgp.com> wrote:
>
> I kind of got around this by putting in my Layout.html:
>
> <t:if test="${isMainSection}">
>
> main
>
> </t:if>
>
> And in Layout.java:
>        public boolean getIsMainSection() {
>                return _parent.isMainSection();
>        }
>
>
> It's not ideal - it'd be better to be able to ask the _parent
> directly rather than going through Layout.java, but this works for
> now, until I learn Tapestry well enough to fix it up.
>
> Now I just need to figure out how to do the else...
>
> R
>
>
> On Oct 4, 2007, at 4:00 PM, Robert A. Decker wrote:
>
> > I'm getting an error:
> > "Could not find a coercion from type
> > com.pgp.licenseserver.pages.Main to type
> > com.pgp.licenseserver.pages._PGPLicenseServerPage. Available
> > coercions:..."
> >
> > But my Main.java extends _PGPLicenseServerPage and so there
> > shouldn't be any coercion necessary.
> >
> > And besides, why should it care what the type is? Can't it just
> > send it the message I'm trying to send and not care about the type?
> >
> >
> > I'm trying to add to the layout example component to give menu-item
> > links at the top of the page and if we're in a particular section
> > of the app have that link not be active, but the other links be
> > active. I do this by having the pages that belong in each section
> > implement an interface for that section. For example, my 'Main'
> > page has its own section:
> >
> > public class Main extends _PGPLicenseServerPage implements
> > _MainSection {...}
> >
> > And in my superclass:
> > public class _PGPLicenseServerPage {
> >       public boolean isMainSection() {
> >               return this instanceof _MainSection;
> >       }
> > }
> >
> > And so in my Layout.html I would like to do something like:
> >
> <t:if test="parent.isMainSection">
> >
> main
> >
> </t:if>
> >
> <t:else>
> >
> <a href="#">main</a>
> >
> </t:else>
> > (I don't think this is right - I haven't been able to find an
> > example of an if/else)
> >
> >
> > I've tried messing around with different ways of calling things but
> > I keep getting various exceptions... Any way to get this to work? I
> > do something like this all of the time in WebObjects and it's quite
> > easy.
> >
> > R
> >
> > ---------------------------------------------------------------------
> > 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
>
>


-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

Re: coercion error?

Posted by "Robert A. Decker" <rd...@pgp.com>.
I kind of got around this by putting in my Layout.html:
									<t:if test="${isMainSection}">
										main
									</t:if>

And in Layout.java:
	public boolean getIsMainSection() {
		return _parent.isMainSection();
	}


It's not ideal - it'd be better to be able to ask the _parent  
directly rather than going through Layout.java, but this works for  
now, until I learn Tapestry well enough to fix it up.

Now I just need to figure out how to do the else...

R


On Oct 4, 2007, at 4:00 PM, Robert A. Decker wrote:

> I'm getting an error:
> "Could not find a coercion from type  
> com.pgp.licenseserver.pages.Main to type  
> com.pgp.licenseserver.pages._PGPLicenseServerPage. Available  
> coercions:..."
>
> But my Main.java extends _PGPLicenseServerPage and so there  
> shouldn't be any coercion necessary.
>
> And besides, why should it care what the type is? Can't it just  
> send it the message I'm trying to send and not care about the type?
>
>
> I'm trying to add to the layout example component to give menu-item  
> links at the top of the page and if we're in a particular section  
> of the app have that link not be active, but the other links be  
> active. I do this by having the pages that belong in each section  
> implement an interface for that section. For example, my 'Main'  
> page has its own section:
>
> public class Main extends _PGPLicenseServerPage implements  
> _MainSection {...}
>
> And in my superclass:
> public class _PGPLicenseServerPage {
> 	public boolean isMainSection() {
> 		return this instanceof _MainSection;
> 	}
> }
>
> And so in my Layout.html I would like to do something like:
> 									<t:if test="parent.isMainSection">
> 								          main
> 								    </t:if>
> 									<t:else>
> 										<a href="#">main</a>
> 									</t:else>
> (I don't think this is right - I haven't been able to find an  
> example of an if/else)
>
>
> I've tried messing around with different ways of calling things but  
> I keep getting various exceptions... Any way to get this to work? I  
> do something like this all of the time in WebObjects and it's quite  
> easy.
>
> R
>
> ---------------------------------------------------------------------
> 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