• Post Reply Bookmark Topic Watch Topic
  • New Topic

custom tag attribute validation

 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am writing a custom tag and one of the attributes is a string. For this attribute I want the user the user to enter one of 5 possible values.

I wanted to know the best way of validating this attribute to make sure the user has added on of the possible 5 values.

What is the best way of doing this?

Thank you

David
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If user means end user and attribute value will be dynamic, you must validate it for yourself.
If user means developer who will use this tag, you can use special api.
search google for TLV (tag library validation)
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are writing a tag used by other developers and you want to validate the value of the attribute, then you may consider using TagExtraInfo (tei) classes. You could override the isValid() method to return true/false. A TagData object is passed to this method which contains the attribute values. This works at translation time and hence if your attribute supports runtime translation (rtexpr value = true), this will not work.

Here are links to some resources
1. http://today.java.net/pub/a/today/2004/02/04/validation.html
2. http://www.onjava.com/pub/a/onjava/2001/01/18/jsptags.html?page=last

ram.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!