You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Simon Stewart <si...@gmail.com> on 2004/11/28 04:43:08 UTC
Getting started with Tapestry
I'm having a hard time getting started with Tapestry and would
appreciate your help and patience. I've gone through the User Guide
and the component guide and it's still heavy going. Are there any
other manuals that I should read? The examples that ship with the
binary distribution need EJBs, which made me shy away from them....
Better yet, is there a tutorial anywhere that introduces Tapestry in a
step by step way, addressing concerns such as how to make forms work
(!) and field validation? The version that I found (covering "Hello
World" to "Hangman") doesn't appear to do this and goes a little fast
for me.
Since I'm used to working with WebWork, I was pleased to see that
Tapestry uses OGNL. Is there any way to interact with it (perhaps to
encourage better handling of null values)? And how do I add my own
type converters?
I'm keen to find my feet with Tapestry, so apologies for the deluge of
questions :)
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Getting started with Tapestry
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Nov 27, 2004, at 10:43 PM, Simon Stewart wrote:
> Better yet, is there a tutorial anywhere that introduces Tapestry in a
> step by step way, addressing concerns such as how to make forms work
> (!) and field validation? The version that I found (covering "Hello
> World" to "Hangman") doesn't appear to do this and goes a little fast
> for me.
Others have chimed in with lots of details on this part of your mail.
I'll emphasize Jamie's suggestion of getting the Workbench application
running locally so you can dissect it. There is a section on the
Workbench example application for form fields and validation.
> Since I'm used to working with WebWork, I was pleased to see that
> Tapestry uses OGNL. Is there any way to interact with it (perhaps to
> encourage better handling of null values)? And how do I add my own
> type converters?
There is an extension I added to hook in a custom type converter. It's
listed as the last entry here:
http://jakarta.apache.org/tapestry/doc/TapestryUsersGuide/
configuration.extensions.html
To hook in your own type converter, register an <extension> with that
name in your .application file, and the value is the fully qualified
class name.
However, after I added that extension to Tapestry a change was made to
the @TextField component to mandate that it binds to a String rather
than Object, so it sort of did away with the usefulness of this
extension (though a registered type converter will be used), sadly. I
would much prefer to be able to bind TextField's to int/Integer,
long/Long, float/Float, Date, etc. To do this now you'll need to use
ValidField instead - which requires more overhead in configuration.
There is not a way, that I know of, to hook in custom null handling -
so you'll have to be sure your object graphs don't have null properties
in them in the OGNL expressions you're drilling into. This would be a
nice addition, though, and not terribly difficult to add in a similar
fashion to the type converter.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Form level validation help
Posted by Michael Engelhart <me...@mac.com>.
Thanks John. I guess I don't understand what you mean by having 2
forms since I don't create a Validator with my method either. I just
use the method of validating my fields in the listeners submit method
and then if there are errors, notify the delegate of them and redisplay
the page (exactly how it's described in the book). The method you're
describing sounds like it requires a lot of duplicate code (does it?)
but I really am not sure what you meant. Either way I have this page
working perfectly except for this bit of field tracking that's not
rendering correctly. If you approached it your way because it's not
possible to do what I'm trying to do then I'd be glad to hear more
about the how/why of your method.
Anyway, my question remains if anyone has any insight into what I may
be doing wrong that's causing this particular field to not render from
my delegate when it's been recorded as having an error.
Thanks
Mike
On Nov 30, 2004, at 4:13 PM, John Studarus wrote:
>
> I normally do this with two forms. The first form
> generates the values for the second form. Then you
> don't need to worry about creating your own validator.
> Just have the submit listener on the first form
> perform all the work to populate the second form.
>
> John
>
>
> --- Michael Engelhart <me...@mac.com> wrote:
>
>> Hi -
>> I have a form that as a text field that takes a city
>> name and when
>> submitted needs to query a database to determine if
>> there are multiple
>> cities that match that name. If there are then the
>> page redisplays
>> and a PropertySelection is rendered with the list of
>> cities that match
>> the city name.
>> I'm trying to use the Validation subsystem to make
>> the FieldLabel's
>> render with my custom delegate but can only get the
>> errors that apply
>> to the TextField to render. I'm attaching the
>> template, page and
>> snippets of java code since it's easier to show it
>> that way.
>> I'm using the technique that's described in the
>> Tapestry in Action.
>>
>> Basically the output of the form error at the top of
>> the page works
>> fine so the delegate is successfully recording the
>> error but the City:
>> field label doesn't get wrapped in the span from my
>> delegate's
>> writeLabelPrefix()/writeLabelSuffix method. When
>> I do this identical
>> thing but pass in a say an empty field which in turn
>> redisplays the
>> page with the TextField component rather then the
>> PropertySelection
>> component, the field label gets wrapped in the
>> <span> and shows up red.
>>
>> Thanks for any help as what I may be doing wrong.
>> My only guess so
>> far is that maybe it has something to do with the
>> contrib:Choose
>> component but since I'm new to tapestry I don't
>> understand enough about
>> how it works to do much detective work.
>>
>> Mike
>> ************** Search. Page ****************
>> <bean name="delegate"
>>
> class="com.earthtrip.site.PropertyCitySearchDelegate"
>> />
>>
>> <component id="ValidSearchLocationTextField"
>> type="TextField">
>> <binding name="value"
>> expression="searchRequest.cityName"/>
>> </component>
>> <component
>> id="ValidSearchLocationPropertySelection"
>> type="PropertySelection">
>> <binding name="value"
>> expression="searchRequest.cityName"/>
>> <binding name="size" expression="4" />
>> <binding name="model" expression="locationSelect"
>> />
>> </component>
>>
>> *************** Search.html **************
>> <span jwcid="@contrib:Choose">
>> <span jwcid="@contrib:When"
>> condition="ognl:locationSelect.locations ==
>> null">
>> <td class="AlignRight">
>> <span jwcid="@FieldLabel"
>> displayName="message:city-field-label"
>>
> field="ognl:components.ValidSearchLocationTextField">City:</span>
>> </td>
>> <td>
>> <input type="text"
>> jwcid="ValidSearchLocationTextField" size="30" />
>> </td>
>> </span>
>> <span jwcid="@contrib:When"
>> condition="ognl:locationSelect.displayAsList">
>> <td class="VerticalAlignTopRight">
>> <span jwcid="@FieldLabel"
>> displayName="message:city-field-label"
>>
> field="ognl:components.ValidSearchLocationPropertySelection">City:</
>>
>> span>
>> </td>
>> <td class="VerticalAlignTop">
>> <select
>> jwcid="ValidSearchLocationPropertySelection">
>> <option value="">Boston, MA, US</option>
>> <option value="">Tampa, FL, US</option>
>> <option value="">New York, NY, US</option>
>> <option value="">Los Angeles, CA, US</option>
>> </select>
>> <!--
>> <span jwcid="@Conditional"
>> condition="ognl:beans.delegate.inError">
>> <span jwcid="@Insert" style="font-size:24px;
>> color:red" value="*" />
>> </span>
>> -->
>> </td>
>> </span>
>> <span jwcid="@contrib:Otherwise">
>> <!-- this is a radio group that's equal to the
>> PropertySelection
>> above but using a group 3 radio buttons instead of a
>> propertySelection
>> -->
>> </span>
>> </span>
>> </span>
>>
>> ************* Search.java *********************
>> public void validateCitySearch( IValidationDelegate
>> delegate) {
>> // SNIP - database related searching which isn't
>> really relevant to
>> the problem of field validation
>> // results is a java.util.List returned from the
>> database with city
>> names
>> if (results.size() > 0) {
>> error =
>> getString("multiple-city-locations-match");
>> recordError(delegate,
>> "ValidSearchLocationPropertySelection", error,
>> null);
>> } else {
>> locationSelect.setLocations(null);
>> error = getString("no-city-locations-match");
>> recordError(delegate,
>> "ValidSearchLocationTextField", error, null);
>> // allows the page to redisplay a single city
>> search textfield with
>> invalid city name intact
>> }
>> }
>>
>> protected void recordError(IValidationDelegate
>> delegate, String
>> componentId, String message, ValidationConstraint
>> constraint) {
>> IFormComponent component = (IFormComponent)
>> getComponent(componentId);
>> delegate.setFormComponent(component);
>> delegate.record(message, constraint);
>> }
>>
>>
>>
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail:
>> tapestry-user-help@jakarta.apache.org
>>
>>
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Read only the mail you want - Yahoo! Mail SpamGuard.
> http://promotions.yahoo.com/new_mail
>
> ---------------------------------------------------------------------
> 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
Re: Form level validation help
Posted by John Studarus <jo...@yahoo.com>.
I normally do this with two forms. The first form
generates the values for the second form. Then you
don't need to worry about creating your own validator.
Just have the submit listener on the first form
perform all the work to populate the second form.
John
--- Michael Engelhart <me...@mac.com> wrote:
> Hi -
> I have a form that as a text field that takes a city
> name and when
> submitted needs to query a database to determine if
> there are multiple
> cities that match that name. If there are then the
> page redisplays
> and a PropertySelection is rendered with the list of
> cities that match
> the city name.
> I'm trying to use the Validation subsystem to make
> the FieldLabel's
> render with my custom delegate but can only get the
> errors that apply
> to the TextField to render. I'm attaching the
> template, page and
> snippets of java code since it's easier to show it
> that way.
> I'm using the technique that's described in the
> Tapestry in Action.
>
> Basically the output of the form error at the top of
> the page works
> fine so the delegate is successfully recording the
> error but the City:
> field label doesn't get wrapped in the span from my
> delegate's
> writeLabelPrefix()/writeLabelSuffix method. When
> I do this identical
> thing but pass in a say an empty field which in turn
> redisplays the
> page with the TextField component rather then the
> PropertySelection
> component, the field label gets wrapped in the
> <span> and shows up red.
>
> Thanks for any help as what I may be doing wrong.
> My only guess so
> far is that maybe it has something to do with the
> contrib:Choose
> component but since I'm new to tapestry I don't
> understand enough about
> how it works to do much detective work.
>
> Mike
> ************** Search. Page ****************
> <bean name="delegate"
>
class="com.earthtrip.site.PropertyCitySearchDelegate"
> />
>
> <component id="ValidSearchLocationTextField"
> type="TextField">
> <binding name="value"
> expression="searchRequest.cityName"/>
> </component>
> <component
> id="ValidSearchLocationPropertySelection"
> type="PropertySelection">
> <binding name="value"
> expression="searchRequest.cityName"/>
> <binding name="size" expression="4" />
> <binding name="model" expression="locationSelect"
> />
> </component>
>
> *************** Search.html **************
> <span jwcid="@contrib:Choose">
> <span jwcid="@contrib:When"
> condition="ognl:locationSelect.locations ==
> null">
> <td class="AlignRight">
> <span jwcid="@FieldLabel"
> displayName="message:city-field-label"
>
field="ognl:components.ValidSearchLocationTextField">City:</span>
> </td>
> <td>
> <input type="text"
> jwcid="ValidSearchLocationTextField" size="30" />
> </td>
> </span>
> <span jwcid="@contrib:When"
> condition="ognl:locationSelect.displayAsList">
> <td class="VerticalAlignTopRight">
> <span jwcid="@FieldLabel"
> displayName="message:city-field-label"
>
field="ognl:components.ValidSearchLocationPropertySelection">City:</
>
> span>
> </td>
> <td class="VerticalAlignTop">
> <select
> jwcid="ValidSearchLocationPropertySelection">
> <option value="">Boston, MA, US</option>
> <option value="">Tampa, FL, US</option>
> <option value="">New York, NY, US</option>
> <option value="">Los Angeles, CA, US</option>
> </select>
> <!--
> <span jwcid="@Conditional"
> condition="ognl:beans.delegate.inError">
> <span jwcid="@Insert" style="font-size:24px;
> color:red" value="*" />
> </span>
> -->
> </td>
> </span>
> <span jwcid="@contrib:Otherwise">
> <!-- this is a radio group that's equal to the
> PropertySelection
> above but using a group 3 radio buttons instead of a
> propertySelection
> -->
> </span>
> </span>
> </span>
>
> ************* Search.java *********************
> public void validateCitySearch( IValidationDelegate
> delegate) {
> // SNIP - database related searching which isn't
> really relevant to
> the problem of field validation
> // results is a java.util.List returned from the
> database with city
> names
> if (results.size() > 0) {
> error =
> getString("multiple-city-locations-match");
> recordError(delegate,
> "ValidSearchLocationPropertySelection", error,
> null);
> } else {
> locationSelect.setLocations(null);
> error = getString("no-city-locations-match");
> recordError(delegate,
> "ValidSearchLocationTextField", error, null);
> // allows the page to redisplay a single city
> search textfield with
> invalid city name intact
> }
> }
>
> protected void recordError(IValidationDelegate
> delegate, String
> componentId, String message, ValidationConstraint
> constraint) {
> IFormComponent component = (IFormComponent)
> getComponent(componentId);
> delegate.setFormComponent(component);
> delegate.record(message, constraint);
> }
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
>
>
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Form level validation help
Posted by Michael Engelhart <me...@mac.com>.
Hi -
I have a form that as a text field that takes a city name and when
submitted needs to query a database to determine if there are multiple
cities that match that name. If there are then the page redisplays
and a PropertySelection is rendered with the list of cities that match
the city name.
I'm trying to use the Validation subsystem to make the FieldLabel's
render with my custom delegate but can only get the errors that apply
to the TextField to render. I'm attaching the template, page and
snippets of java code since it's easier to show it that way.
I'm using the technique that's described in the Tapestry in Action.
Basically the output of the form error at the top of the page works
fine so the delegate is successfully recording the error but the City:
field label doesn't get wrapped in the span from my delegate's
writeLabelPrefix()/writeLabelSuffix method. When I do this identical
thing but pass in a say an empty field which in turn redisplays the
page with the TextField component rather then the PropertySelection
component, the field label gets wrapped in the <span> and shows up red.
Thanks for any help as what I may be doing wrong. My only guess so
far is that maybe it has something to do with the contrib:Choose
component but since I'm new to tapestry I don't understand enough about
how it works to do much detective work.
Mike
************** Search. Page ****************
<bean name="delegate"
class="com.earthtrip.site.PropertyCitySearchDelegate" />
<component id="ValidSearchLocationTextField" type="TextField">
<binding name="value" expression="searchRequest.cityName"/>
</component>
<component id="ValidSearchLocationPropertySelection"
type="PropertySelection">
<binding name="value" expression="searchRequest.cityName"/>
<binding name="size" expression="4" />
<binding name="model" expression="locationSelect" />
</component>
*************** Search.html **************
<span jwcid="@contrib:Choose">
<span jwcid="@contrib:When" condition="ognl:locationSelect.locations ==
null">
<td class="AlignRight">
<span jwcid="@FieldLabel" displayName="message:city-field-label"
field="ognl:components.ValidSearchLocationTextField">City:</span>
</td>
<td>
<input type="text" jwcid="ValidSearchLocationTextField" size="30" />
</td>
</span>
<span jwcid="@contrib:When"
condition="ognl:locationSelect.displayAsList">
<td class="VerticalAlignTopRight">
<span jwcid="@FieldLabel" displayName="message:city-field-label"
field="ognl:components.ValidSearchLocationPropertySelection">City:</
span>
</td>
<td class="VerticalAlignTop">
<select jwcid="ValidSearchLocationPropertySelection">
<option value="">Boston, MA, US</option>
<option value="">Tampa, FL, US</option>
<option value="">New York, NY, US</option>
<option value="">Los Angeles, CA, US</option>
</select>
<!--
<span jwcid="@Conditional" condition="ognl:beans.delegate.inError">
<span jwcid="@Insert" style="font-size:24px; color:red" value="*" />
</span>
-->
</td>
</span>
<span jwcid="@contrib:Otherwise">
<!-- this is a radio group that's equal to the PropertySelection
above but using a group 3 radio buttons instead of a propertySelection
-->
</span>
</span>
</span>
************* Search.java *********************
public void validateCitySearch( IValidationDelegate delegate) {
// SNIP - database related searching which isn't really relevant to
the problem of field validation
// results is a java.util.List returned from the database with city
names
if (results.size() > 0) {
error = getString("multiple-city-locations-match");
recordError(delegate, "ValidSearchLocationPropertySelection", error,
null);
} else {
locationSelect.setLocations(null);
error = getString("no-city-locations-match");
recordError(delegate, "ValidSearchLocationTextField", error, null);
// allows the page to redisplay a single city search textfield with
invalid city name intact
}
}
protected void recordError(IValidationDelegate delegate, String
componentId, String message, ValidationConstraint constraint) {
IFormComponent component = (IFormComponent) getComponent(componentId);
delegate.setFormComponent(component);
delegate.record(message, constraint);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Getting started with Tapestry
Posted by Benjamin Tomasini <bt...@neteverything.com>.
I have found these to be helpful:
http://www.sandcastsoftware.com/articlesandtutorials/brownbag/
http://weblogs.java.net/blog/johnreynolds/archive/2004/10/learn_by_teachi_1.html
And of course, the book by Howard is great.
Ben
On Sat, 2004-11-27 at 22:43, Simon Stewart wrote:
> I'm having a hard time getting started with Tapestry and would
> appreciate your help and patience. I've gone through the User Guide
> and the component guide and it's still heavy going. Are there any
> other manuals that I should read? The examples that ship with the
> binary distribution need EJBs, which made me shy away from them....
>
> Better yet, is there a tutorial anywhere that introduces Tapestry in a
> step by step way, addressing concerns such as how to make forms work
> (!) and field validation? The version that I found (covering "Hello
> World" to "Hangman") doesn't appear to do this and goes a little fast
> for me.
>
> Since I'm used to working with WebWork, I was pleased to see that
> Tapestry uses OGNL. Is there any way to interact with it (perhaps to
> encourage better handling of null values)? And how do I add my own
> type converters?
>
> I'm keen to find my feet with Tapestry, so apologies for the deluge of
> questions :)
>
> Regards,
>
> Simon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
--
Benjamin Tomasini
NetEverything, Inc.
1-877-270-1391
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Getting started with Tapestry
Posted by Srinivasan Ranganathan <sr...@gmail.com>.
Welcome aboard.
http://www2.cpttm.org.mo/cyberlab/softdev/tapestry/ gives a nice intro
to tapestry. There are more links at
http://wiki.apache.org/jakarta-tapestry/ in the Sample Applications
section. And of course, theres always the mailing list.
Hope this helps.
Cheers
Srini
On Sun, 28 Nov 2004 14:43:08 +1100, Simon Stewart
<si...@gmail.com> wrote:
> I'm having a hard time getting started with Tapestry and would
> appreciate your help and patience. I've gone through the User Guide
> and the component guide and it's still heavy going. Are there any
> other manuals that I should read? The examples that ship with the
> binary distribution need EJBs, which made me shy away from them....
>
> Better yet, is there a tutorial anywhere that introduces Tapestry in a
> step by step way, addressing concerns such as how to make forms work
> (!) and field validation? The version that I found (covering "Hello
> World" to "Hangman") doesn't appear to do this and goes a little fast
> for me.
>
> Since I'm used to working with WebWork, I was pleased to see that
> Tapestry uses OGNL. Is there any way to interact with it (perhaps to
> encourage better handling of null values)? And how do I add my own
> type converters?
>
> I'm keen to find my feet with Tapestry, so apologies for the deluge of
> questions :)
>
> Regards,
>
> Simon
>
> ---------------------------------------------------------------------
> 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
Re: Getting started with Tapestry
Posted by Jamie Orchard-Hays <ja...@dang.com>.
Also make sure you look at the Gotchas page on the wiki early on. It
will save you pain later.
You should get the Workbench running in either Tomcat or Jetty, and
look at the source code for those pages in it to see how those
components are used.
One thing, the ant task for running the workbench in Jetty
(run-workbench) needs a modification: change jetty-jdk1.2.jar to
jetty.jar.
Another thing: open Tapestry-3.0.1/config/common.properties and find #
----- JDOM Library, version b8 -----. Every where "b8" is referenced,
change this to "1.0". You'll end up with references to jdom-1.0.jar,
jdom-1.0, and jdom-1.0.tar.gz. b8 is no longer available and the build
will fail if you leave it in. (I've submitted a patch for this already.
Lastly, in the config/build.config file set the absolute path to your
Jetty installation. When you run ant run-workbench, the missing
external libraries will be downloaded and then jetty will launch the
workbench app on localhost:8080/workbench/app
Jamie
On Nov 27, 2004, at 10:43 PM, Simon Stewart wrote:
> I'm having a hard time getting started with Tapestry and would
> appreciate your help and patience. I've gone through the User Guide
> and the component guide and it's still heavy going. Are there any
> other manuals that I should read? The examples that ship with the
> binary distribution need EJBs, which made me shy away from them....
>
> Better yet, is there a tutorial anywhere that introduces Tapestry in a
> step by step way, addressing concerns such as how to make forms work
> (!) and field validation? The version that I found (covering "Hello
> World" to "Hangman") doesn't appear to do this and goes a little fast
> for me.
>
> Since I'm used to working with WebWork, I was pleased to see that
> Tapestry uses OGNL. Is there any way to interact with it (perhaps to
> encourage better handling of null values)? And how do I add my own
> type converters?
>
> I'm keen to find my feet with Tapestry, so apologies for the deluge of
> questions :)
>
> Regards,
>
> Simon
>
> ---------------------------------------------------------------------
> 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