*
The moose likes Struts and the fly likes Drop down Value and Submit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Drop down Value and Submit" Watch "Drop down Value and Submit" New topic
Author

Drop down Value and Submit

Chinni Bujji
Ranch Hand

Joined: Jan 31, 2007
Posts: 60
Hi,

I have two questions here

i have 2 jsp pages.

first question?
in one jsp page i have link to go to second jsp page to get a value.
how do i get the value from second jsp page to first jsp page ?

second question ?
in the second jsp page i have list box
once i select a value in the list box the submit button should be enabled after value selection

then when i click submit it should take me the value that i selected to the first jsp page.

i am using struts-html tags

any suggestions or ideas with some samples are highly appreciated

thanks alot
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Before I can answer this, I would need to know how these two pages are being displayed. Did you use Struts Tiles to display them both in the same physical page? Did you use HTML Frames with both JSPs in the same frameset in separate frames? Did the first JSP open up a popup window to display the second?


Merrill
Consultant, Sima Solutions
Chinni Bujji
Ranch Hand

Joined: Jan 31, 2007
Posts: 60
the first jsp page opens the second page as POP up
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
There is more than one way to do this, but here's what I'd suggest.

When you open a window using the JavaScript window.open() function, the window you opened has a property named "opener" that refers to the parent window. Once you have that reference, you can refer to or modify any element in the parent window. For example, opener.document.myForm.myText refers to a text input named myText in form myForm in the parent window.

Here's how I'd do it:
  • create a JavaScript Function that gets the input value in the second JSP and sets the value of some input in the parent JSP. (I'd suggest either a hidden field or a read-only text input).
  • Once the values are set the function should close the current window
  • Use the onclick even of the button to call the function

  • If you do it this way, the second JSP doesn't submit at all, but just uses JavaScript to set the value in the first JSP. Then, when the user submits the first JSP, all the values will be sent to the server.
    Chinni Bujji
    Ranch Hand

    Joined: Jan 31, 2007
    Posts: 60
    hello merill

    can you give me some sample code
    Merrill Higginson
    Ranch Hand

    Joined: Feb 15, 2005
    Posts: 4864
    The parent JSP:

    The popup window:

    [ March 26, 2007: Message edited by: Merrill Higginson ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Drop down Value and Submit
     
    Similar Threads
    Struts combo box
    Query in Action Form
    Dropdown values for JSP
    ArrayList gets duplicate values in JSP
    Passing Parameters through JSP