aspose file tools*
The moose likes JSF and the fly likes How to invoke rich:modalPanel from another page ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to invoke rich:modalPanel from another page ?" Watch "How to invoke rich:modalPanel from another page ?" New topic
Author

How to invoke rich:modalPanel from another page ?

Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
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


Abhishek
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

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

Customer surveys are for companies who didn't pay proper attention to begin with.
Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
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

Joined: Jun 25, 2001
Posts: 16305
    
  21

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

Joined: Mar 28, 2006
Posts: 259
thanks for the help, its working now.
Abhishek Reddy
Ranch Hand

Joined: Mar 28, 2006
Posts: 259
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

Joined: Jun 25, 2001
Posts: 16305
    
  21

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to invoke rich:modalPanel from another page ?