• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add EL expressions in tag body manually

 
Arun kumar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone please explain me the procedure of adding a EL expression in the body of the TAG

ex
If the tag invocation is
<myTag:showStock>
The Stock details are
${strStock}
</myTag:showStock>

Is it possible for me add a extra EL expression from my tag class on top of bottom of the body ??

Is it possible for me to create a new JspFragment object so that i can get the old body contents and add my new contents to the top or bottom of the tag body ?

I tried doing getJspContext().getOut().write("${extraBodyContentsInfo}") , I know this is a stupid solution as am just writing a string to the body ,But this is what i need to do .

I need to add a new EL expression and pass the attributes from my Tag class and call the invoke().

Please help me
 
Arun kumar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never got any reply till now .
Anyway thanks guys , i found out the solution .This solution is applicable only for Apache container.

To add a EL Expression to the body of the tag is not directly possible though , all you can do is evaluate that EL expression and display the output to the JSP.



This code has been replaced instead of


Actually i want to implement it in this way for tag which will be reused for sorting collection and displaying few properties of the object , So in that case they will be passing only the variableName
In that case i cant dynamically call get<VariableName>()
I should have used reflection or a commonbeanutils to do this , for which am totally new.
My tag implementation looks like
<myTag:group groupBy="name" showAttributes="dog.name,dog.color">

</myTag:group>
In this case i need to display data like
Person 1
Dog1 Black
Dog2 Brown
Person 2
Dog3 Black
Dog4 Brown

I hope this is the right way to implement this , If any corrections please leave your comments
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic