Using Tapestry 4 beta, I was successfully able to create a standard page (which has validation with custom delegate) in Tapestry using annotations. I was then able to delete my page specification file. Will I remove all page specification files from my applications? Probably not, I will take it case by case. I will definetly be marking persistent fields as well as assets as annotations. Components will be another story, based on their complexity. Below is an example of having a page without a page specifcation file (I have included the contents of the page specification file in comments for comparison):

public abstract class DataEntry extends BasePage implements PageRenderListener{ /** Creates a new instance of Home */
   public DataEntry() {
}
   @InjectState("visit")
   public abstract Visit getVisitObject();
@InjectState("global") public abstract Global getGlobalObject(); /* <bean name="delegate" class="com.scottwalter.sandbox.tapestry4.MyDelegate" property="delegate"/>
   */
   @Bean
   public abstract MyDelegate getDelegate();
public void pageBeginRender(PageEvent event) {
       if(getPerson()==null) {
           System.out.println("creating new person");
           Person p = new Person();
           p.setFirstName("Scott");
           p.setLastName("Walter");
           setPerson(p);
       }
} @Persist
   public abstract Person getPerson();
   public abstract void setPerson(Person p);
/*
     <component id="firstNameField" type="TextField">
       <binding name="value" value="ognl:person.firstName"/>
       <binding name="validators" value="required,minLength=3,myname"/>
       <binding name="displayName" value="First Name"/>
     </component>
   */
   @Component( id="firstNameField", type = "TextField",
               bindings = {    "value = ognl:person.firstName",
                               "displayName = First Name",
                               "validators = required,minLength=3,myname"
}) public abstract TextField getFirstNameField(); /*
     <component id="lastNameField" type="TextField">
       <binding name="value" value="ognl:person.lastName"/>
<binding name="validators" value="required,minLength=3,lastnamer=walter"/>
       <binding name="displayName" value="Last Name"/>
     </component>
   */
   @Component( id="lastNameField", type = "TextField",
               bindings = {    "value = ognl:person.lastName",
                               "displayName = Last Name",
                               "validators = required,minLength=3"
              })
   public abstract TextField getLastNameField();
/*
      <component id="ageField" type="TextField">
           <binding name="value" value="ognl:person.age"/>
           <binding name="translator" value="number,pattern=#"/>
           <binding name="displayName" value="Age"/>
           <binding name="validators" value="required,min=0,max=120"/>
       </component>
   */
   @Component( id="ageField", type = "TextField",
               bindings = {    "value = ognl:person.age",
                               "translator = number,pattern=#",
                               "displayName = Your Age",
                               "validators = required,min=5,max=10"
}) public abstract TextField getAgeField(); public void doForm() { }
--

Scott F. Walter         Scott F. Walter
Principal Consultant
Vivare, Inc.

E: [EMAIL PROTECTED]
E: [EMAIL PROTECTED]
Visit scottwalter.com <http://scottwalter.com> --Point.  Click.  Explore!




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to