• 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

Silly question

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question which is probably easy to answer, but cos I'm new to JSP I don't know how to do it myself:

Is there any way to pass a value from a selected row straight back in to Java? What I'm trying to do is take a load of selected values and add them together to form a total. This is basicsally what I'm trying:

<%
int subtotal = 0;

subtotal += <jbo:ShowValue datasource="paygroup1" dataitem="MY_TOTAL" ></jbo:ShowValue>;

%>

But it gives me an error when I try to do it like this.

I'm sure I've done something like this before when I used JSP a few years back, but I can't remember what.

Any help is much appreciated!
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cant do that.
From the limited information in your post,



<jbo...> is obviously some kind of custom tag. Tags output html to the browser. You cannot append tag outputs to the jsp source in the fashion you have used. It simply doesnt work that way.

One way out is to set this data as a pageContext attribute from within the tag and then have some mechanism (another co-operating outer tag perhaps) that would total up the value.

cheers,
ram.
 
Dan D Taylor
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply, Ram.

Yes, sorry for the lack of info. I'm using JDeveloper, and the jbo's are Java Business Object tags - the standard data access tags in JDev 10g.

I'm creating my select statement with a CreateViewObject tag, binding it with a DataSource, then retrieving the rows with a ShowValue tag as shown above.

So there's no other easy way you can access the contents of the data tags directly from the Java source? I'd have thought this would be one of the most fundamental requirements in JSP?!

Many thanks for your help anyway!

Dan
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What it is you cannot do is to embed custom actions (formerly known as custom tags) in JSP scriplets. It is the custom action that must provide the ability to export its results to a scoped or scripting variable.
 
Dan D Taylor
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, thanks for your help.

I've found another way to do it now - I've just written a PL/SQL function which adds up and returns all the totals for me.

I guess I should have taken the easy option in the first place instead of trying to complicate things!

Cheers,

Dan.
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic