• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Working on Tapestry Validation

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I have moved on to try and get a grasp of the validation in Tapestry down. And I need a bit of clarification.

I have a login form that consists of a username and a password field. All I want to do initially is specify that these fields are required. Originally, my Login.page looked like this:



So, the first change I started to make was to declare a bean called "delegate" and noticed I needed to define my own class for this. This is confusion #1.

The next change I needed to make was to add a bean declaration called "required" that used a class StringValidator. No problem.

Confusion #2: I then needed to add a component declaration for my ValidField. This was pretty self explanitory until I got to the part where I say something like:

<binding name="value" expression="???" />

The book has a JavaBean which it uses for this purpose. I am just creating a Login form. I don't want to code a bean just for this. I thought that there should be someway to specify this from the following property-specification:

<property-specification name="username" type="java.lang.String"/>

But I am not sure if this is a) possible and b) how I would do it if it is possible.

Note also that the delegate class I need to define would handle the changes made to the html like change the color of the FieldLabel and even highlight the textfield bla bla. I don't really care about this right now. All I care about is notifying the user that the fields are required. So is there a class that I can specify for that delegate that is already in the Tapestry API rather than having to create my own and extend ValidationDelegate?

I hope this made some sense. I have to abuse Howard and Geoff and all the other experts before the promo is over and they all leave.
[ May 26, 2004: Message edited by: Gregg Bolinger ]
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
confusion #1
You can use org.apache.tapestry.valid.ValidationDelegate that is already in the Tapestry API.

confusion #2
You can do just like this:

After the form is rewinded, the property "username" of the Login page will be set.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Looluo Zhu:
confusion #1
You can use org.apache.tapestry.valid.ValidationDelegate that is already in the Tapestry API.

confusion #2
You can do just like this:

After the form is rewinded, the property "username" of the Login page will be set.



Great! Thanks Looluo. I appreciate the help. I'm sure I'll be back with more questions on this.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, problems I am running into now...

I have the following Login.page



And relevent part of my Login.html



And here is my Login.java


The error I am getting is:


Method 'public abstract java.lang.String examples.Login.getUserName()' (declared in class examples.Login) has no implementation in class examples.Login (or enhanced subclass examples.Login$Enhance_3).



Now before I started with the validation stuff, my Login.html was a little different. For the input of the username I had the following line:



I know how this worked. The ognl:userName was used to use the abstract method getUserName() in my Login.java class. So I am assuming my error is because of the difference between the 2 files now but I am unclear on how to correct this.

Thanks.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


When I added the property-specification for username back into my Login.page I typed it as username instead of userName



I haven't put the validation back in to test it yet, but I assume at least my original problem will go away

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic