File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

how to get javascript value into bean

sam sami

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

I think I originally got this code from the Core JSF 3 book, with a bit of help from BalusC

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):




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


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

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

main.xhtml (changes)

showMenu.js (changes)

I hope this is going to be of some help.

sam sami

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:
subject: how to get javascript value into bean
It's not a secret anymore!