• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to invoke rich:modalPanel from another page ?

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

I am new to JSF, I need help in invoking rich:modalPanel from another page ?

For example:
Consider Page1.xhtml
In the above page, I have to provide a link somewhere in the middle of the form which popups the modalPanel. This modalPanel is in another Page (say modalPage.xhtml)

The modalPanel content should be in a different page as it is needed in the multiple pages of the application.

Note: This modalPanel has another form which takes some inputs from the user.

I have used <ui:include> tag to include the content of the modelPanel.xhtml and used the below code to invoke the modalPanel (in Page1.xhtml), but it is not working.

<a href="javascript:Richfaces.showModalPanel('modalPanelID')">Display Modal Panel</a>

I think it is not finding the id 'modalPanelID' of rich:modalPanel tag which is present in another page, but not sure about that.

Please provide your thoughts.

Thanks
Abhishek
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If there's not a JavaScript sandbox rule that prohibits one web page from controlling another web page, there should be.

However, the easiest way to use a common dialog (modalPanel) in more than one page (View) definition is to put it in a Facelets component and include that component on the calling pages. You must, of course, be careful to put the include statement OUTSIDE of any form definitions on the calling pages.

Here's some code I use:



This particular button has the following special properties:

1. Can be used even when the form containing it has invalid/incomplete data (immediate="true", ajaxSingle="true")
2. Invokes an AJAX listener to (re)initialize the properties of the form's backing bean(s) (a4j/action=)
 
Abhishek Reddy
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply,

I did the way you have suggested, but failed.... below is the code



modalPanel.xhtml


The above code is not working, could you please tell me where I went wrong ?

Thanks

 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I prefer to put my dialog definitions at the beginning (before the form), rather than the end, but I don't think it actually matters.

Most likely you problem comes from using more than one "f:view" in the View Definition. You don't need to do that.
 
Abhishek Reddy
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the help, its working now.
 
Abhishek Reddy
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Tim,

I have one more question for you.

When i click on the modal panel link, the current page is getting refreshed. Inside the modalPanel window, I have save and close button...when I click either of the buttons backend page(modalPanel calling page) is getting refreshed. How to stop refreshing the backend page (modalPanel calling page) ?

Thanks,
Abhishek
 
Tim Holloway
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abhishek Reddy wrote:Hello Tim,

I have one more question for you.

When i click on the modal panel link, the current page is getting refreshed. Inside the modalPanel window, I have save and close button...when I click either of the buttons backend page(modalPanel calling page) is getting refreshed. How to stop refreshing the backend page (modalPanel calling page) ?

Thanks,
Abhishek



Restrict the reRender on the button's action to only the dialog (and its children). If you're not using an AJAX commandButton (a4j:commandButton), you need to, since the normal h:commandButton does refresh the entire page - no partial page refresh.
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic