• Post Reply Bookmark Topic Watch Topic
  • New Topic

Silly question

 
Dan D Taylor
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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!
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!