• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to add EL expressions in tag body manually

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
If you like strawberry rhubarb pie, try blueberry rhubarb (bluebarb) pie. And try this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic