• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Opening popUp window in JSF

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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 = window.open(PopUpWindow,null,"height=400,width=400,status=yes,toolbar=no,menubar=no,location=no, scrollbars=1");
mywindow.moveTo(300,100);
}

</script>

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


<h:commandLink value=" Prepopulate KYC Parties"
rendered="#{userSessionInfo.userTasks[param.WorkItemId].partyObjType}"
onclick="open_win('prePopKYC.jsf')">
</h:commandLink>

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?
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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="window.open('http://www.google.com', 'WindowName', 'dependent=yes, menubar=no, toolbar=no'); return false;" value="#">
<h: outputText value="popup" />
</h: outputLink>
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That shouldn't matter and this is unrelated to the actual problem.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
bacon. tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic