Win a copy of High Performance Python for Data Analytics this week in the Python forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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.
 
Thank you my well lotioned goddess! Here, have my favorite tiny ad!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic