This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Working on Tapestry Validation

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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

 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!