• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

taglib question

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From "Study Kit" page 307:
in the TLD, it has:

And, in the JSP file, it uses the "if" tag like this:

Now my question is: where does it say the attribute "condition" is a boolean? What if, in the JSP page, I used the "if" tag like this?
<test:if condition="1" />
At translation time, there will be no error. It will blow up at request time if the tag handler class only takes in boolean values for the "condition" parameter.
Is this logic correct?
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An interesting question. I can't say for sure but I think there are two important points to remember:
1)The example was used to show the use of JSP body-content, not as a full-blown example of the inner workings of a specific tag, or of the possible problems resulting from use of incompatible type.
2)I assume that you don't use a custom tag without some knowledge of it. So if this were instead an example of a the inner workings of this specific sampleLib.IfTag class then the the text would probably indicate that the class/tag expects the "condition" attribute to be a boolean.
Since there is an optional "type" subelement for any attribute though, it seems like it might be wise to include the type when it's something other than String, which is the default. But I really haven't seen type mentioned much in either of the certification books I've read. Given your question though and the problems that seem like they could occur from using the wrong type it seems to me like a good idea to include it in the attribute list.
 
Coco Lee
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, I agree! I think "type" should definitely be mandatory.
I guess the simple answer to my question would be simply to test it. However, my excuse is that I am taking the test Wednesday and I am cramming the taglib section, so I'd rather be lazy and have people answer my questions here
I'm just trying to predict what would happen...which probably explains why I get into trouble often...
Thanks for your response Ken....
 
Ken Januski
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good luck, Coco. I'm taking mine on Tuesday.
Ken
And the question was actually good preparation for test as I had to look up the subelements of attribute. Let's hope we both get asked about it on our tests.
 
reply
    Bookmark Topic Watch Topic
  • New Topic