• 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

using Formbean field in scripting

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy!

How do I, easily, turn a formbean field into a scripting fild for use in JSP?

Eg. If I wan't to do some advanced calculation on a field for use in the layout?

Regards, Henrik
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to use your ActionForm bean in a JSP scriptlet, you have to retrieve it from the scope in which it is saved. So, if myActionForm is in request scope, the code to retrieve it would be:

<%
MyActionForm myActionForm = (MyActionForm)request.getAttribute("myActionForm");
%>

Once you have this reference to the bean, you can call any of it's methods, just as you would in regular Java.

Another alternative might be to put the complex calculation into a getter method in the ActionForm bean (e.g. getMyComplexData()). If you do this, you can access the results of the calculation with <bean:write name="myActionForm" property="myComplexData" />
 
reply
    Bookmark Topic Watch Topic
  • New Topic