• 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

set bean value with onlick event

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems like a basic question but maybe I'm wrong.
I want to set a form bean value on my page using a link.
the value for the link is

the reason is I would like it to go to another report where the dropdowns should default to this value.
the name of the bean is reportBean
the property is the same here: dialdCode
let me know if I need to explain this better
thanks for your suggestions
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you mean that you want to be able to click on a link on your page and, without submitting the form/page, set a value in the underlying form?

I guess that I'm not too sure what your question is. If this IS your question, you may want to try using javascript to access the form value and set it to whatever you need.

Hope this helps.
 
Gran Roguismo
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks brad,
what I would like to do is for it to follow the link rather than submitting the forum, this is true. I would actually like it to submit on that second link, but that's something I'm going to have to work out in the action I think.

I have thought of JS, but I am having one problem with it. I can't get the value out of the JS and put it back into the bean.
Here is the code that I had pertaining to it.




you can see on line 4 there is a problem. Ideas?

I seem to be having some problem with the javascript posting in this forum, so I have removed the declaration and changed onck from the regular call
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
function drillDown(dialdCntryCode) {
<%reportForm.setDialdCntryCode(dialdCntryCode); session.setAttribute("passBean", reportForm); %>
}

It looks like you are trying to make JS communicate with a scriptlet. You can't do that because the scriptlet completes before the page ever reaches the client's browser.

Scriptlets can "talk" to JS, but JS can not "talk" to scriptlets.
 
Gran Roguismo
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
right, that's why I was looking for the alternative. Is there perhaps a tag or the like that I can use to solve this instead then? At least that would be the ideal thing.
 
Gran Roguismo
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in other words, is there some way I can use something like

to get the result I want
[ March 29, 2005: Message edited by: Gran Roguismo ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's what I think you want to do. Let me know if I'm wrong.
  • user clicks on a link that does not submit the page, but sets a value so that the following page can use it
  • next page picks up the changed information when the page is submitted


  • If this is what you want to do, do the following:
  • create a hidden field <input type="hidden" name="dialdCntryCode" >
  • create a link with an onclick event that sets the value of the hidden field, as in: document.MyForm.dialdCntryCode.value = 'xyz'
  • if your form bean has a property for dialdCntryCode, the property will be populated by Struts for use in the next page.

  •  
    Gran Roguismo
    Ranch Hand
    Posts: 77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    right, that is what I am looking to do.
    alright, so like mark said, the scriptlets are going to process beforehand. And one of those was setting the form into session where I could pull it down on the next page. Obviously this isn't going to work because this input comes after that session variable has already been set.
    Since both of these pages are using the same form and I want the same data, is there a way I can get it to not reset the form either in the jsp or action or perhaps another way I can put the form into the session through the javascript (I don't think js has that ability)?
     
    No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic