aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes setting a row value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "setting a row value" Watch "setting a row value" New topic
Author

setting a row value

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I am not certain whether this should be here or be in struts, jsp forum but would proceed...

The application is in struts-2


I have 2 JSP's... The 1st JSP has a 5 column table... The values for the 4th and 5th columns are obtained from the next JSP...These values are currently residing in a JS variable prepared in JSP-2.

Scenario:-->

In 1st JSP, I select row1 and click on 'gotoNext' button to go to next JSP in order to prepare values for the 4th and 5th columns...

In JSP-2, I prepared the 2 values for that row using Javascript...

Now on click of back button in JSP2 I need to go back to JSP1 and set these 2 values in 2 empty fields of the row that I previously selected...


I don't know the correct way to do it and these are a few options circulating in my mind viz...

1)Should I send these values unsing an AJax call?
2)How to pass those 2 JS values from JSP-2 and set them in empty fields of that row of JSP1

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

The back button will simply recall the previous page. You'll need another approach. perhaps you can describe what you are really trying to accomplish?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Yes...It simply calls the page an there lies the issue...

Here is the actual scenario...

There is Rules.jsp...

it has a table with only a header having 7 columns. This jsp is within the application flow and it's not the starting one!

case1:


Now I want to add a row. I have an add button below the table which gives a form (with buttons OK,Cancel)for filling the row values 2,3,4,5 as the first column is the row number i am setting in my JS.

Now when I click OK button, a row(dynamically added) along with the first 5 elements are added to the table.Now the table has 1 row with elements 6,7 empty

Now Values 6,7 are empty and are to be fetched from the next jsp which is CA.jsp

I select the row, click on button 'gotoCA', to go to CA.jsp.

In CA.jsp I calculated values and have them in 2 Javascript variables...

Now in CA.jsp to go to rules.jsp I have 'AddRule' button.

On click of this button when I go back to rules.jsp I should first show rules.jsp(as it was earlier , with 1 row(selected) ,5 values filled ) and now also filled with values 6,7 .

Now,how should I approach?? Kindly tell me the perfect way to do this a little detail... (1. I was trying to get the table of rules.jsp in CA.jsp and set values for 6,7 but it dint look rite to me)

need Ajax? S:Action?

(If required I would post the code although it's lengthy)

Nothing is helping me here to find the "right" way... Thank you!






Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

I don't understand the need for all the page transitions. Why aren't you just doing Ajax in a single page?
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Bear please elaborate... It would be great if it can be done such way ...I hope you understood what I wrote....

An Ajax call to pass those values to the previous jsp??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

That's my point -- why is there even a need for a "previous JSP"?

It sounds like you are updating a single page. Why the need for other JSPs?
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
NO The values of the last two columns have to be prepared bt CA.jsp and they have to be sent back to previous jsp..That's a mandate and obeys the requirement
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Pradeep Adibatla wrote:NO The values of the last two columns have to be prepared bt CA.jsp and they have to be sent back to previous jsp..That's a mandate and obeys the requirement

You haven't answered why.

If you are going to obstinate and not be open to the possibility that what you are doing is not the best way, there's not much we can do to help you.

Going to another JSP page just to fetch new data is not necessary and just creates problems. Why cannot you just fetch the data with an Ajax request?
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Well I will clear the doubt clouds as to why that jsp is required...

The 2 values which i am talking about are not just values but they are 2 conditions.The CA.jsp has an expression builder which is used to form expressions like a+b-c*d.
So I prepare the 2 values in the expression builder and click on AddToRule button in CA.jsp.These two values should now be set in the empty columns of the row selected in the rules.jsp...



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

A JSP is not a good tool for performing calculations. They should be only used to render views.

Why not perform your calculations in a servlet that can be invoked via Ajax, and hence not cause you to lose your page state?
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Well it's a requirement Bear! and I have to stick to it.

It says that there should be a CA.jsp ....

with dropdown boxes aligned in an order that would create expression. I am creating the expression in Javascript(by the dropdown id and storing it in a JS variable) and then showing the user the expression created by him in a textArea below it( by assigning the JS variable to textArea).

Now on Click of the button I should go back and somehow paste these values in the row selected...

So I have to do it this way...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

The requirement states what technology to use? Ridiculous.
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Well Bear, Its basically struts 2 and should have a UI... anything in this would do...what do you suggest?
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Long time ,but this is more like it...


I have 2 jsp's...

JSP1 contains a table with 6 columns and button like this...


---------------------------------------------------------------------------------------------------------------------------------------------------------
RName RAuthor RStartDate REndDate Condition Action
--------------------------------------------------------------------------------------------------------------------------------
Row1: name1 auth1 xxx yyy
-------------------------------------------------------------------------------------------
name2 auth2 xx yy
--------------------------------------------------------------------------------------------
name3 auth3 x y
---------------------------------------------------------------------------------------------------
. ...........
.. .............

GOTOJSP2 (button)

---------------------------------------------------------------------------------------------------------------------------------------------------------------

In the above jsp1 it is observed that the last wo values of each row is empty and they are calculated and obtained from jsp2 .
The user selects any 1 of the rows and clicks on "GOTOJSP2" to proceed to next jsp....

suppose if the user selected row 1,he needs to obtain the condition and action for row 1 from jsp2

Jsp2 has a table ,an expression builder and a button "AddtoRow" like this.......

-----------------------------------------------------------------------------------------------------------------------------------
(1) RSName Condition Action
-------------------------------------------------
Name1 a+b*c=20 d=21
-------------------------------------------------
.........
..........

(2) Expression builder(to forn above expressions which is done by using Javascript and the above values are calculated in this expression bulder ,stored in
javascript variables and set to the cells of the row dynamically

(3) AddToRow (button)

-----------------------------------------------------------------------------------------------------------------------------------


Now on click of AddToROw button,the control should goto jsp1 and set the 2 values to the emty cells of row1 of jsp1...

What are the ways to tranfer and set these values??? how should I pass the javascript values and set them in the previous jsp... kindly elaborate the ways of achieving this...

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting a row value
 
Similar Threads
a JS value passing issue
2 jsp's data passing
passing JS values in struts-2
using OGNL
passing JS values between 2 pages