You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ea...@gmx.de on 2004/02/29 22:07:37 UTC

Re: Overriding renderComponent Part V

Hm.....ok, I solved the bit with the path now....but here again comes the
problem that it needs
to have an html template file that corresponds to the WeatherBlock. :-(

I already added allow-body="no" to the component specification....





"Could not find template for component Home/$WeatherBlock in locale de."

> In your .application file create a line:
> 
>     <component-type type="WeatherBlock"
> specification-path="/com/mysite/presentation/components/WeatherBlock.jwc"
> />
> 
> 
> 
> 
> In the HTML code you should write
>     <span jwcid="@WeatherBlock" />
> 
> OR
> 
> if you want to define in the .page file
>     <component id="weatherBlockId" type="WeatherBlock"/>
> and in your HTML file
>     <span jwcid="weatherBlockId" />
> 
> I hope I wrote it correctly.
> Norbi
> 
> ----- Original Message ----- 
> From: <ea...@gmx.de>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Sunday, February 29, 2004 8:57 PM
> Subject: Re: Overriding renderComponent Part III
> 
> 
> > When I do that I get:
> >
> > 'com.mysite.presentation.components.WeatherBlock' is not a valid
> component
> > type.
> >
> >
> > If I enter Insert, at least it does not complain ;-)
> >
> >
> > Does anyone know an example of a component that does insert html but
> that
> > does not require a template?
> >
> > Thanks!
> >
> >
> > > You most definitely need to say type="WeatherBlock".... you want to
> use
> > > the WeatherBlock component, not the Insert component.  Right?
> > >
> > > I'm surprised the Insert component is not complaining for lack of a
> > > 'value', actually.  Is it not required?  Shouldn't it be?
> > >
> > > jwcid is *not* the type of component you are using, it is just a made
> > > up name.  Change it to 'xyz', and work from there :)
> > >
> > > Erik
> > >
> > >
> > > On Feb 29, 2004, at 1:59 PM, easy-to-remember@gmx.de wrote:
> > >
> > > > I dont think it needs to be mentioned within the application file,
> or
> > > > does
> > > > it?
> > > > According to the manual, this needs to be a type not a class, in
> this
> > > > case
> > > > an Insert component.
> > > > [type string A component type to instantiate.]
> > > >
> > > > There are no error messages, but simply nothing appears. I even
> added
> > > > the
> > > > isStateful and trigger methods now, methods...although I am not sure
> > > > whether
> > > > they are necessary at all in this case.
> > > >
> > > >
> > > > public abstract class WeatherBlock extends AbstractComponent
> implements
> > > > IDirect {
> > > >
> > > > public abstract IActionListener getListener();
> > > > public abstract Object getParameters();
> > > >
> > > > public void renderComponent(IMarkupWriter writer, IRequestCycle
> > > > cycle) {
> > > >
> > > > StringBuffer buffer = new StringBuffer();
> > > > buffer.append("<table border=1>");
> > > > buffer.append("<tr>");
> > > > buffer.append("<td>");
> > > > buffer.append("heeellloo");
> > > > buffer.append("</td>");
> > > > buffer.append("</tr>");
> > > > buffer.append("</table>");
> > > > writer.print(buffer.toString());
> > > > }
> > > >
> > > > public boolean isStateful() {
> > > > return false;
> > > > }
> > > > public void trigger(IRequestCycle cycle) {
> > > >
> > > > IActionListener listener = getListener();
> > > >
> > > > if (listener == null)
> > > > throw Tapestry.createRequiredParameterException(this, "listener");
> > > >
> > > > listener.actionTriggered(this, cycle);
> > > >
> > > > }
> > > >
> > > > }
> > > >
> > > > Within the html template:
> > > >
> > > > <span jwcid="WeatherBlock"/>
> > > >
> > > > and witin the page definition:
> > > >
> > > >
> > > > <page-specification
> > > > class="org.apache.tapestry.pets.presentation.pages.HomePage">
> > > > <description>Simple Home Page</description>
> > > > <component id="WeatherBlock" type="Insert"/>
> > > > </page-specification>
> > > >
> > > > WeatherBlock jwc
> > > >
> > > > <component-specification
> > > >
> class="org.apache.tapestry.pets.presentation.components.WeatherBlock"/>
> > > >
> > > > Has anyone ever tried that?
> > > >
> > > >
> > > >
> > > > Toby
> > > >
> > > >
> > > >
> > > >>
> > > >>> <component id="WeatherBlock" type="Insert"/>
> > > >> This line seems to be incorrect. The component type should be some
> > > >> "WeatherBlock" (see your .application file what is the name of your
> > > >> weather
> > > >> component).
> > > >>
> > > >> Norbi
> > > >>
> > > >> ----- Original Message -----
> > > >> From: <ea...@gmx.de>
> > > >> To: "Tapestry users" <ta...@jakarta.apache.org>
> > > >> Cc: <ta...@jakarta.apache.org>
> > > >> Sent: Sunday, February 29, 2004 9:51 AM
> > > >> Subject: Re: Overriding renderComponent Part II
> > > >>
> > > >>
> > > >>> Oh, another additional question:
> > > >>>
> > > >>> In theory, if this block is to appear on 50 pages, how can I avoid
> > > >> having
> > > >> to
> > > >>> add it on every single page specification? Just asking as if it
> > > >>> should
> > > >> ever
> > > >>> change I would only want to edit on file not 50....
> > > >>>
> > > >>> Thanks!
> > > >>>
> > > >>> Toby
> > > >>>
> > > >>> I took the Petshop example and just wanted to enter a tiny little
> > > >>> Block
> > > >> with
> > > >>> some weather information.
> > > >>> Even though it is a petshop.... ;-)
> > > >>>
> > > >>> It should render itself from a database later on, so I would like
> to
> > > >>> get
> > > >>> away with no html templates files at all.
> > > >>>
> > > >>>
> > > >>> // WeatherBlock.java
> > > >>>
> > > >>> public  class WeatherBlock extends AbstractComponent  {
> > > >>>
> > > >>> public void renderComponent(IMarkupWriter writer, IRequestCycle
> > > >>> cycle) {
> > > >>>
> > > >>> StringBuffer buffer = new StringBuffer();
> > > >>> buffer.append("<table border=1>");
> > > >>> buffer.append("<tr>");
> > > >>> buffer.append("<td>");
> > > >>> buffer.append("heeellloo");
> > > >>> buffer.append("</td>");
> > > >>> buffer.append("</tr>");
> > > >>> buffer.append("</table>");
> > > >>> writer.print(buffer.toString());
> > > >>> }
> > > >>>
> > > >>> }
> > > >>>
> > > >>> // Home.page .... Petshop example
> > > >>>
> > > >>> <page-specification
> > > >>> class="org.apache.tapestry.pets.presentation.pages.HomePage">
> > > >>> <description>Simple Home Page</description>
> > > >>> <component id="WeatherBlock" type="Insert"/>
> > > >>> </page-specification>
> > > >>>
> > > >>>
> > > >>> // within Home.html
> > > >>>
> > > >>> <span jwcid="WeatherBlock"/>
> > > >>>
> > > >>>
> > > >>> Is there anything missing?
> > > >>>
> > > >>> Thanks!
> > > >>>
> > > >>>> Check if you're extending BaseComponent, instead of
> > > >>>> AbstractComponent.
> > > >>>> AFAIK BaseComponents must have a template and AbstractComponents
> > > >> don't.
> > > >>>>
> > > >>>> On Saturday, February 28, 2004, at 06:11  PM,
> > > >>>> easy-to-remember@gmx.de
> > > >>>> wrote:
> > > >>>>
> > > >>>>> 2. Why does it still want to have a template file even if I
> render
> > > >> the
> > > >>>>> html
> > > >>>>> myself?
> > > >>>>
> > > >>>>
> > >
> >>>> -------------------------------------------------------------------- 
> > > >>>> -
> > > >>>> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> > > >>>> For additional commands, e-mail:
> > > >>>> tapestry-user-help@jakarta.apache.org
> > > >>>>
> > > >>>
> > > >>>
> > >
> >>> ---------------------------------------------------------------------
> > > >>> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> > > >>> For additional commands, e-mail:
> > > >>> tapestry-user-help@jakarta.apache.org
> > > >>>
> > > >>>
> > > >>
> > > >>
> ---------------------------------------------------------------------
> > > >> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> > > >> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> > > >>
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 


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