Luc Peerdeman wrote:
Hi Scott,
It is interesting this is possible, however, I see this example more
as a good illustration of why the approach of 'everything in one file'
is not a good idea. I think it is ugly and not readable, and will
impact maintainability negatively. Furthermore, it is solving a
'problem' that imho is not a real problem. Spindle will let me jump
between the parts of a component quite easily and that is all I need.
All aspects of a component have their own file which makes things much
simpler.
Cheers, Luc.
Scott F. Walter wrote:
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() { }
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
I do agree, I don't think annotations should mean the elimination of the
page specification file. First and foremost developers should be
thinking about maintainability. As you can see from my little demo page
if you have many components on page, using annotations will really start
to make your page class unreadable or at the very least hard to
understand. But annotations do have their place in my opinion, marking
fields as pesistent and using assets.
--
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]