You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Captain Cid <ca...@indiatimes.com> on 2009/06/22 22:18:28 UTC
Return HTML
Hi,
I am new to tapestry
i have 2 questions
firstly if i want to render some html from a function in page...how will i
do...
suppose template has ${show}...
and i define
public String getShow() {
return "<div>Hello</div>";
}
it changes < to lt; gt; etc
secondly i have a component Info with a variable say "private String
description"
and function
public String getDescription() {
return description;
}
how can i use it in template ??
${component:Info.description} doesnt work !
--
View this message in context: http://www.nabble.com/Return-HTML-tp24154619p24154619.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
Re: Return HTML
Posted by Captain Cid <ca...@indiatimes.com>.
package tapestry.pages;
public class showpage {
@Component
private Info Info;
}
---
package tapestry.components;
public class Info {
@Inject
private Request request;
private String description="some text";
public String getDescription() {
return description;
}
}
----
showpage.tml
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<body>
<t:Info>${description}</t:Info> <!--doesn't work..how do i call component
function or access variable-->
</body>
</html>
offcourse using ${ComponentDescription} by defining
getComponentDescription() is one way out :)
i need to read more about @Environtment service..thnx !
Piero Sartini-3 wrote:
>
>> actually, it is not defined in the page class
>
> Seems like you need to provide more information for us to understand your
> issue.
>
>> in my showpage class i use
>>
>> @Component
>> private Info Info;
>>
>> so it still gives error saying
>> tapestry.pages.showpage does not contain a property named 'description'
>
> Lets assume your Info component has a public property called description.
> Is
> this correct?
>
> In your page you use this component with <t:info/> and the @Component
> annotation.
>
> Now you want access to a public property of info within the page. Never
> did
> something like this, but I would guess that you need to do something like
> this
> in your page class:
>
> public String getComponentDescription() {
> return info.getDescription();
> }
>
> That said, normally you want to use @Environmental inside your components
> for
> communication with your enclosing components (and pages).
>
> Piero
>
>>
>> Piero Sartini-3 wrote:
>> >> >> secondly i have a component Info with a variable say "private
>> String
>> >> >> description"
>> >> >> and function
>> >> >> public String getDescription() {
>> >> >> return description;
>> >> >> }
>> >> >>
>> >> >> how can i use it in template ??
>> >> >> ${component:Info.description} doesnt work !
>> >
>> > Just use ${description} in the template file of the component.
>> >
>> > Piero
>> >
>> > ---------------------------------------------------------------------
>> > 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://www.nabble.com/Return-HTML-tp24154619p24156413.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
Re: Return HTML
Posted by Piero Sartini <li...@pierosartini.de>.
> actually, it is not defined in the page class
Seems like you need to provide more information for us to understand your
issue.
> in my showpage class i use
>
> @Component
> private Info Info;
>
> so it still gives error saying
> tapestry.pages.showpage does not contain a property named 'description'
Lets assume your Info component has a public property called description. Is
this correct?
In your page you use this component with <t:info/> and the @Component
annotation.
Now you want access to a public property of info within the page. Never did
something like this, but I would guess that you need to do something like this
in your page class:
public String getComponentDescription() {
return info.getDescription();
}
That said, normally you want to use @Environmental inside your components for
communication with your enclosing components (and pages).
Piero
>
> Piero Sartini-3 wrote:
> >> >> secondly i have a component Info with a variable say "private String
> >> >> description"
> >> >> and function
> >> >> public String getDescription() {
> >> >> return description;
> >> >> }
> >> >>
> >> >> how can i use it in template ??
> >> >> ${component:Info.description} doesnt work !
> >
> > Just use ${description} in the template file of the component.
> >
> > Piero
> >
> > ---------------------------------------------------------------------
> > 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: Return HTML
Posted by Captain Cid <ca...@indiatimes.com>.
actually, it is not defined in the page class
in my showpage class i use
@Component
private Info Info;
so it still gives error saying
tapestry.pages.showpage does not contain a property named 'description'
Piero Sartini-3 wrote:
>
>> >> secondly i have a component Info with a variable say "private String
>> >> description"
>> >> and function
>> >> public String getDescription() {
>> >> return description;
>> >> }
>> >>
>> >> how can i use it in template ??
>> >> ${component:Info.description} doesnt work !
>
> Just use ${description} in the template file of the component.
>
> Piero
>
> ---------------------------------------------------------------------
> 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://www.nabble.com/Return-HTML-tp24154619p24155844.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
Re: Return HTML
Posted by Piero Sartini <li...@pierosartini.de>.
> >> secondly i have a component Info with a variable say "private String
> >> description"
> >> and function
> >> public String getDescription() {
> >> return description;
> >> }
> >>
> >> how can i use it in template ??
> >> ${component:Info.description} doesnt work !
Just use ${description} in the template file of the component.
Piero
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Return HTML
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 22 Jun 2009 19:27:54 -0300, Captain Cid
<ca...@indiatimes.com> escreveu:
> i used
>
> @Component(parameters =
> {"id=123" })
> @Property
> private productInfo productInfo;
>
> and ${productInfo.description} worked. Thnx
:)
> ya but i guess better would be to define function in page class to
> retrieve
> information from component !
Most of the time, this is the best way of doing it.
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Return HTML
Posted by Captain Cid <ca...@indiatimes.com>.
i used
@Component(parameters =
{"id=123" })
@Property
private productInfo productInfo;
and ${productInfo.description} worked. Thnx
ya but i guess better would be to define function in page class to retrieve
information from component !
Thiago H. de Paula Figueiredo wrote:
>
> Em Mon, 22 Jun 2009 18:13:13 -0300, Captain Cid
> <ca...@indiatimes.com> escreveu:
>
>>> Render queue error in Expansion[ComponentResources[expansion
>>> Info.Description]]: Component showPage does not contain an embedded
>>> component with id 'productInfo.Description'. Available components:
>>> outputraw, outputraw_0, Info.
>
> You cannot access component properties directly in templates. You can
> accomplish the same by
>
> @InjectComponent
> @Property
> private ProductInfo productInfo
>
> And use ${productInfo.description} in the template. By the way, is very
> unusual to use component properties in templates.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> 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://www.nabble.com/Return-HTML-tp24154619p24156680.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
Re: Return HTML
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 22 Jun 2009 18:13:13 -0300, Captain Cid
<ca...@indiatimes.com> escreveu:
>> Render queue error in Expansion[ComponentResources[expansion
>> Info.Description]]: Component showPage does not contain an embedded
>> component with id 'productInfo.Description'. Available components:
>> outputraw, outputraw_0, Info.
You cannot access component properties directly in templates. You can
accomplish the same by
@InjectComponent
@Property
private ProductInfo productInfo
And use ${productInfo.description} in the template. By the way, is very
unusual to use component properties in templates.
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Return HTML
Posted by Captain Cid <ca...@indiatimes.com>.
Thiago H. de Paula Figueiredo wrote:
>
> Em Mon, 22 Jun 2009 17:18:28 -0300, Captain Cid
> <ca...@indiatimes.com> escreveu:
>
>> Hi,
>
> Hi!
>
>> I am new to tapestry
>
> Welcome!
>
>> i have 2 questions
>>
>> firstly if i want to render some html from a function in page...how will
>> i
>> do...
>> suppose template has ${show}...
>> and i define
>> public String getShow() {
>> return "<div>Hello</div>";
>> }
>>
>> it changes < to lt; gt; etc
>
> Use the OutputRaw component and leave your method as is.
>
>> secondly i have a component Info with a variable say "private String
>> description"
>> and function
>> public String getDescription() {
>> return description;
>> }
>>
>> how can i use it in template ??
>> ${component:Info.description} doesnt work !
>
> Please post the error message and the stack trace, because sayint it
> doesn't work is not enough information for us to thelp you.
> ^^^^^^
>
> Basically i want to know...how can i access component variable or
> component function from template file
>
> Error shown was :
>
> An unexpected application exception has occurred.
>
> Render queue error in Expansion[ComponentResources[expansion
> Info.Description]]: Component showPage does not contain an embedded
> component with id 'productInfo.Description'. Available components:
> outputraw, outputraw_0, Info.
>
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> 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://www.nabble.com/Return-HTML-tp24154619p24155556.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
Re: Return HTML
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 22 Jun 2009 17:18:28 -0300, Captain Cid
<ca...@indiatimes.com> escreveu:
> Hi,
Hi!
> I am new to tapestry
Welcome!
> i have 2 questions
>
> firstly if i want to render some html from a function in page...how will
> i
> do...
> suppose template has ${show}...
> and i define
> public String getShow() {
> return "<div>Hello</div>";
> }
>
> it changes < to lt; gt; etc
Use the OutputRaw component and leave your method as is.
> secondly i have a component Info with a variable say "private String
> description"
> and function
> public String getDescription() {
> return description;
> }
>
> how can i use it in template ??
> ${component:Info.description} doesnt work !
Please post the error message and the stack trace, because sayint it
doesn't work is not enough information for us to thelp you.
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org