• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

custom tag doubt!

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello ranchers,

Please consider the following code snippet from Enthuware mock.

Consider a JSP page that contains the following code:


Assuming the following implementation details, identify the correct statements.

1. x: outer is implemented by OuterTag.java, which extends SimpleTagSupport.

2. x:middle is implemented by MiddleTag.java, which extends BodyTagSupport and has a body-content of tagdependent.

3. x:inner is implemented by InnerTag.java, which extends BodyTagSupport and has a body-content of tagdependent.



1. OuterTag can get a reference to InnerTag by calling TagSupport.findChildrenWithClass() method.
2. MiddleTag can get a reference to OuterTag by calling TagSupport.findAncestorWithClass(this, OuterTag.class).
3.InnerTag can get a reference to OuterTag by calling TagSupport.findAncestorWithClass(this, OuterTag.class) method.

4.MiddleTag can get a reference to OuterTag by calling TagSupport.getParent() method.
5. InnerTag can get a reference to MiddleTag by calling TagSupport.getParent() method.

Above question ask to select only one correct answer. I think there should be more then one correct options are there??
i guess options 2, 3 should be the correct answers, because TagSupport.findAncestorWithClass method which exists in the TagSupport class is used to find the enclosing tag by passing approriate parameter.

Please correct me if I am wrong.

Thanks
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Infact option 5
5. InnerTag can get a reference to MiddleTag by calling TagSupport.getParent() method. also seems to be the correct one.

TagSupprt.getParent returns a object of type Tag. Moreover MiddleTag also declared as a classic tag(TagSupport).
 
Chithra Salam
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think option 5 InnerTag can get a reference to MiddleTag by calling TagSupport.getParent() method is the correct answer.

Option 2nd 3 are wrong as Classic tag cannot have Simple tag as parent but Simple tag can have Classic tag as parent and access it thr getParent or findAncestorWithClass.

Thanks,
Chithra Salam
[scwcd in progress,scjp 1.4 85%]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic