File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Opening popUp window in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Opening popUp window in JSF" Watch "Opening popUp window in JSF" New topic

Opening popUp window in JSF

Anks Gupta

Joined: Mar 27, 2007
Posts: 21

I need to open a popup from a commandLink in my JSF page. On click of commandLink i need to pass a parameter to the URL of PopUp. Parameter is available in the parent JSF page through param.WorkItemId where WorkItemId is getting passed to the parent page using URL appending like http://localhost:8080/MyProj/page.xhtml?WorkItemId=xxx

I need to append this WorkItem Id while opening popup also so that its available there also.

I tried in the following manner.
I am new to javascript so not sure if i m doing it write.
<script type="text/javascript" language = "JavaScript">
function open_win(page)

var popUp = document.getElementById('initPopUp').value;
var PopUpWindow= page+"?WorkItemId="+popUp;
mywindow =,null,"height=400,width=400,status=yes,toolbar=no,menubar=no,location=no, scrollbars=1");


<h:inputHidden id = "initPopUp" value = "${param.WorkItemId}">

<h:commandLink value=" Prepopulate KYC Parties"

While doing this when i click on hyperlink i get a JS error: Object required.

Can anybody please help me out with this or let me know a workaround?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
This is not a JSF problem, but a JS problem.

I´ll give you one hint: Javascript runs at the client side and intercepts on HTML only. JSF runs at the server side and generates HTML output only (along with JS, CSS and another client side languages). So when writing or debugging Javascript, you should initially NOT look at the JSF code, but at its generated HTML output. View the page source in your favourite webbrowser.
Hiren Dutta

Joined: Dec 30, 2005
Posts: 10
If you are trying to open Popup on link click try to use <h: outputLink> instead of <h:commandLink> and use onclick event to open Popup....

<h: outputLink onclick="'', 'WindowName', 'dependent=yes, menubar=no, toolbar=no'); return false;" value="#">
<h: outputText value="popup" />
</h: outputLink>
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
That shouldn't matter and this is unrelated to the actual problem.
Kumaresh Vidhyasagar
Ranch Hand

Joined: Dec 05, 2008
Posts: 30
1. Create the link (String) with the parameter added and bind the String variable to the onclick attribute.
2. In the popup (.jsp) file, retrieve the passed parameter and use it.
I agree. Here's the link:
subject: Opening popUp window in JSF
jQuery in Action, 3rd edition