You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Theo vN <th...@gmail.com> on 2005/03/18 11:21:40 UTC

implement PageValidateListener vs override BasePage.validate()

Hello

What's the difference between implementing PageValidateListener and do
validation in the pageValidate(PageEvent event)  as opose to
overriding the BasePage's validate method.
Both seems to work. But how does Tapestry handle each case?

I've seen an example somewhere that shows how to get the service
parameters from a call of an external link - this example overrides
the validate method, but, I guess, one can achieve the same by getting
the cycle from the event and to the same?

-- 
Cheers
Theo

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


Re: 3.1 - adding custom ServiceEncoder and custom Service

Posted by Howard Lewis Ship <hl...@gmail.com>.
Examples from the Tapestry 3.1 workbench:

Contributing a service (overriding the factory home service) and
adding a chart service:

 <contribution configuration-id="tapestry.services.ApplicationServices">
    <service object="service:Home"/>
    <service object="service:Chart"/>
  </contribution>
 
  
  <service-point id="Chart"
interface="org.apache.tapestry.engine.IEngineService">
    <invoke-factory model="primitive">
      <construct class="org.apache.tapestry.workbench.chart.ChartService">
        <set-object property="exceptionReporter"
value="infrastructure:requestExceptionReporter"/>
      </construct>
    </invoke-factory>
  </service-point>
  
  <service-point id="Home"
interface="org.apache.tapestry.engine.IEngineService">
    <invoke-factory model="primitive">
      <construct class="org.apache.tapestry.workbench.WorkbenchHomeService">
        <set-object property="responseRenderer"
value="infrastructure:responseRenderer"/>
        <set-object property="linkFactory" value="infrastructure:linkFactory"/>
        <set-object property="pageName"
value="app-property:org.apache.tapestry.home-page"/>
      </construct>
    </invoke-factory>
  </service-point>  


Enabling use of built-in service encoders:

  <contribution configuration-id="tapestry.url.ServiceEncoders">
    <page-service-encoder id="direct" extension="direct" service="direct"/>
    <page-service-encoder id="page" extension="page" service="page"/>
    <asset-encoder id="asset" path="/assets/"/>
    <extension-encoder id="ext" extension="svc" after="*"/>
  </contribution>

Extra web.xml configuration for those encoders:


  <servlet-mapping>
    <servlet-name>workbench</servlet-name>
    <url-pattern>*.page</url-pattern>
  </servlet-mapping>
  
  <servlet-mapping>
    <servlet-name>workbench</servlet-name>
    <url-pattern>*.direct</url-pattern>
  </servlet-mapping>
  
  <servlet-mapping>
    <servlet-name>workbench</servlet-name>
    <url-pattern>*.svc</url-pattern>
  </servlet-mapping>
  
  <servlet-mapping>
    <servlet-name>workbench</servlet-name>
    <url-pattern>/assets/*</url-pattern>
  </servlet-mapping>


Contributing a custom (rather than built-in) encoder:

  <contribution configuration-id="tapestry.url.ServiceEncoders">
    <encoder id="...." object="service:MyEncoderService"/>
  </contribution>





On Sat, 19 Mar 2005 22:39:21 +0900, Manri Offermann
<ta...@eastbeam.co.jp> wrote:
> Hello all,
> 
> I am trying to add a custom ServiceEncoder and Service in tapestry 3.1, but
> still couldn't figure out how. The documentation says:
> 
> "Engine services are now defined using HiveMind, in the
> tapestry.services.ApplicationServices configuration point. "
> 
> but it doesn't say exactly how it is done ...
> 
> Does anybody have a sample of how to declare new Services in 3.1?
> 
> Thanks,
> 
> manri
> 
> for my simple TestServiceEncoder I have added the following
> 
> hivemodule.xml
> 
>  <contribution configuration-id="tapestry.url.ServiceEncoders">
>   <my-service-encoder id="page" extension="html"/>
>  </contribution>
> 
> How and where do I add this?
> 
>    <element name="my-service-encoder">
>     <attribute name="id" required="true" unique="true"></attribute>
>     <attribute name="before"></attribute>
>     <attribute name="after"></attribute>
>     <attribute name="extension" required="true"></attribute>
>     <rules>
>      <create-object
>       class="org.apache.tapestry.services.impl.ServiceEncoderContribution"/>
>      <read-attribute attribute="id" property="id"/>
>      <read-attribute attribute="before" property="before"/>
>      <read-attribute attribute="after" property="after"/>
>      <invoke-parent method="addElement"/>
>      <create-object
>       class="com.eastbeam.ext.tapestry.encoder.TestServiceEncoder"/>
>      <read-attribute attribute="extension" property="extension"/>
>      <invoke-parent method="setEncoder"/>
>     </rules>
>    </element>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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


3.1 - adding custom ServiceEncoder and custom Service

Posted by Manri Offermann <ta...@eastbeam.co.jp>.
Hello all,

I am trying to add a custom ServiceEncoder and Service in tapestry 3.1, but 
still couldn't figure out how. The documentation says:

"Engine services are now defined using HiveMind, in the 
tapestry.services.ApplicationServices configuration point. "

but it doesn't say exactly how it is done ...

Does anybody have a sample of how to declare new Services in 3.1?


Thanks,

manri



for my simple TestServiceEncoder I have added the following

hivemodule.xml

 <contribution configuration-id="tapestry.url.ServiceEncoders">
  <my-service-encoder id="page" extension="html"/>
 </contribution>


How and where do I add this?

   <element name="my-service-encoder">
    <attribute name="id" required="true" unique="true"></attribute>
    <attribute name="before"></attribute>
    <attribute name="after"></attribute>
    <attribute name="extension" required="true"></attribute>
    <rules>
     <create-object
      class="org.apache.tapestry.services.impl.ServiceEncoderContribution"/>
     <read-attribute attribute="id" property="id"/>
     <read-attribute attribute="before" property="before"/>
     <read-attribute attribute="after" property="after"/>
     <invoke-parent method="addElement"/>
     <create-object
      class="com.eastbeam.ext.tapestry.encoder.TestServiceEncoder"/>
     <read-attribute attribute="extension" property="extension"/>
     <invoke-parent method="setEncoder"/>
    </rules>
   </element> 



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


Re: implement PageValidateListener vs override BasePage.validate()

Posted by Theo vN <th...@gmail.com>.
Thank you, yes it does.


On Fri, 18 Mar 2005 11:36:43 -0800, Paul Ferraro <pm...@columbia.edu> wrote:
> The validate() method is the old mechanism of validating a page.  If an
> application had a common set of validation to perform across a set of
> pages (typically something like: is the user logged in?  if not, go to
> login page), those pages would typically extend from the some common
> page implementation that implemented validate().
> 
> With the advent of PageValidateListener, components too (not just pages)
> can participate in validation simply by implementing
> PageValidateListener.  Rather than be constained by an inheritence
> hierarchy of base pages, page validation logic can now reside in common
> components (like a Border component).
> 
> Did that make sense?
> 
> Paul
> 
> Theo vN wrote:
> 
> >Hello
> >
> >What's the difference between implementing PageValidateListener and do
> >validation in the pageValidate(PageEvent event)  as opose to
> >overriding the BasePage's validate method.
> >Both seems to work. But how does Tapestry handle each case?
> >
> >I've seen an example somewhere that shows how to get the service
> >parameters from a call of an external link - this example overrides
> >the validate method, but, I guess, one can achieve the same by getting
> >the cycle from the event and to the same?
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Cheers
Theo

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


Re: implement PageValidateListener vs override BasePage.validate()

Posted by Paul Ferraro <pm...@columbia.edu>.
The validate() method is the old mechanism of validating a page.  If an 
application had a common set of validation to perform across a set of 
pages (typically something like: is the user logged in?  if not, go to 
login page), those pages would typically extend from the some common 
page implementation that implemented validate().

With the advent of PageValidateListener, components too (not just pages) 
can participate in validation simply by implementing 
PageValidateListener.  Rather than be constained by an inheritence 
hierarchy of base pages, page validation logic can now reside in common 
components (like a Border component).

Did that make sense?

Paul

Theo vN wrote:

>Hello
>
>What's the difference between implementing PageValidateListener and do
>validation in the pageValidate(PageEvent event)  as opose to
>overriding the BasePage's validate method.
>Both seems to work. But how does Tapestry handle each case?
>
>I've seen an example somewhere that shows how to get the service
>parameters from a call of an external link - this example overrides
>the validate method, but, I guess, one can achieve the same by getting
>the cycle from the event and to the same?
>
>  
>


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