• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pass textbox value to JSP custom tag

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am probably missing something small here, but cannot see what it is. Can somebody please spend some time reading through my issue and point me in the right direction.

I want to pass a value of textbox/hidden field to a custom tag in my Struts2 application - I am not sure if this question belongs to the JSP forum or the Struts forum.

If I hard-code a value for num in , it works. But I need this value from a bean in the Value Stack and can't hard-code it. I can see that the textbox is getting the right value - I am able to validate this through Fiddler.

TLD file:


JSP - shows a compile error in Eclipse


I tried - nothing happens, it does not seem to even go into my tag and no errors.

I also tried this in my Tag class, I am able to retrieve everything (like servername, protocol etc from request) but request parameters from the PageContext. Is it not considered as being part of the same request while calling the custom tag?



I also tried this approach from Struts user guide
and added this to the JSP:



This generates OGNL syntax errors in the second line. I do not know what to change in the TLD to accomplish this.

Many thanks



 
Sue Temple
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had asked this question in the JSP forum, but I found a couple of links on using OGNL in custom tags and modified my code accordingly.

But I get a ClassNotFoundException for TagUtils.class. I opened the struts core jar and I can see this class there. I can also clearly see that the struts core jar is packed into my ear file. I am using Struts 2.1.6 deployed on JBoss 4.3 - in my deploy ear task, I include all jars from the Struts libs. Can somebody please help me, I have been stuck with this all weekend long and its plain frustrating not going anywhere with what seems like a simple problem!

(This needs to be moved to the Struts forum, but looks like I do not have access to move it myself.)

JSP:

Tag.java:


TLD file:


Error:



Thanks!

 
Sue Temple
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I answered my own question. This is probably a work-around, but works.. phew..



I would still be very interested to know why TagUtils threw a ClassNotFoundException (from my previous post in this thread), if anybody has an answer.






 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using JSP EL will also give access to the value stack--assuming iPage is an action property then ${iPage.numPages} is a valid EL expression (assuming there's a getNumPages()).
 
Sue Temple
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.

And also, I found out why PageUtils was throwing the ClassNotFound error - my code was in a new package and I had to manually add that to the build file.
 
reply
    Bookmark Topic Watch Topic
  • New Topic