wood burning stoves 2.0*
The moose likes JSF and the fly likes how to get javascript value into bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "how to get javascript value into bean" Watch "how to get javascript value into bean" New topic
Author

how to get javascript value into bean

sam sami
Greenhorn

Joined: Dec 22, 2010
Posts: 18
I am having command links on my.jspx page, when I rigth-click on that command links my menupopup get executed.
I have put onmouseover javascript event, using that I am getting the value of that link.

now my problem is I want that value in backing bean. for that i have used hidden textbox but value is not getting displayed init.

so, how can I get the value of link in backing bean without pageload.
Brendan Healey
Ranch Hand

Joined: May 12, 2009
Posts: 218

It makes it a lot easier if you post up some code, but I think I get it. You display a popup menu,
select an option which navigates to a target page. The target page knows which option was
selected.

I think I originally got this code from the Core JSF 3 book, with a bit of help from BalusC
http://balusc.blogspot.com/2006/06/communication-in-jsf.html.

I think the easiest way to do it is with URL parameters so that you don't require a hidden
input field. As a starting point you have a commandButton (you use a commandLink with a
right click but ignore that):

main.xhtml


showMenu.js


menuContents.xhtml


Then you need to be able to access the parameters in the page. There is an implicit object "param" for
this purpose:

editPage.xhtml


You can access the parameter from the editPage backing bean also:

EditPageBackingBean.java


There are some significant limitations of this simple example, whilst menuContents is passing
parameters to editPage it's all static data. You can pass parameters to menuContents.xhtml like
this:

main.xhtml (changes)


showMenu.js (changes)


I hope this is going to be of some help.

Brendan.
sam sami
Greenhorn

Joined: Dec 22, 2010
Posts: 18
Thanks for replay,

My problem is I am not getting the value of selected node in backingbean, that's why I am using JavaScript.

Process -
1) tree in which tree node is defined as commandlink.
2) When I right click on tree node, I'll get menupopup which is having options like Open, Deleet etc.
3)When I click on any option, I have to get the selected Node and the menuitem value in backingbean for next process.

test.jspx -



.js (JavaScript)

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get javascript value into bean
 
Similar Threads
passing hidden field value to backing bean
A viewpage, a table and two backing beans
I need to open a popup from a jsf page.
How get DefaultMutableTreeNode using node text or node value in jsf
getting value of command link which is in series panel