-
1. Re: modal panel as confirmation box?
jucobb2 Feb 29, 2008 1:18 PM (in response to janson12)I've done this multiple times in my site without any problems. What is it about this that isnt working, are you just missing a rerender? Do you have any code you can post?
-
2. Re: modal panel as confirmation box?
janson12 Mar 1, 2008 6:26 AM (in response to janson12)my code looks similar as following:
<h:commandButton actionListener="#{AdminHandler.delAdmin}" value="#{msg.delete}" onclick="Richfaces.showModalPanel('delAdmConf')">
<f:attribute name="selectedId" value="#{item.id}"/>
</h:commandButton>
For a normal js-confirmation-box deletion or non-deletion would dependent on the return value of the js-function. I've tried to call the AdminHandler.delAdmin function from within the modalPanel-code after the confirmation, however the respective item.id then gets lost. -
3. Re: modal panel as confirmation box?
janson12 Mar 1, 2008 6:49 AM (in response to janson12)..ups..i use an a4j:commandButton of course..
-
4. Re: modal panel as confirmation box?
genkito Mar 2, 2008 8:48 PM (in response to janson12)there is a similar process in one of my works. i will try to explain my method here. in fact when the button or image or link (whatever on that column of table) of a row is clicked, i put the index on a sessionbean. after that using oncomplete property of a4j support open the modal panel. after that if the user clicks on cancel just close the modal panel, if user confirms that call the delete action and it gets the selected index from session bean and deletes it. dead simple in fact:) here the sample codes from my work. hope this answer helps:
when the table row clicked: call action that writes the index in session bean<a4j:support action="#{APage.submitDeleteIndex}" event="onClick" oncomplete="Richfaces.showModalPanel('AreYouSureModalPanel')"/>
public void submitDeleteIndex(){ int index = gelSelectedRow(); getActionsSessionBean().setActionTypeDelete(true); getActionsSessionBean().setDeleteIndex(index); }
if cancel button of modal panel is clicked: just close modal panelonclick="Richfaces.hideModalPanel('AreYouSureModalPanel')"
if yes button of modal panel is clicked: call action that deletes item<a4j:support action="#{APage.deleteSelectedItem}" event="onclick" oncomplete = "Richfaces.hideModalPanel('AreYouSureModalPanel')" reRender="A_PANEL"/>
public void deleteSelectedMenuItem(){ int rowIndex = getActionsSessionBean().getDeleteIndex();
-
5. Re: modal panel as confirmation box?
janson12 Mar 3, 2008 7:11 AM (in response to janson12)thanks genkito, your post helped me a lot. my current solution is to save the selected item in the sessionmap and call the delete function as shown in your example from within the modal panel.
regards, jens -
6. Re: modal panel as confirmation box?
massep Mar 4, 2008 11:44 AM (in response to janson12)This topic's is very interesting.
I'm trying to implement a modalPanel to replace a javascript Confirm().
But I can't put my finger on how to implement that kind of popup dialog.
The way I have it now (without richfaces) is:
<h:commandButton id="submitButtonAppl" action="#{portFolioAction.verifyAndSubmitForm}" onclick="var answer=of_isSubmitPermitted('#{navigationBean.languageSite}');if (answer){of_setInputField(document.forms[0],'form_id',#{item.form_id});this.submit();} else {return false;};" type="button">
My javascript method, of_isSubmitPermitted(), is basically a call to Confirm().
As you can see, the Action will not be executed because the page won't be submitted, if the user clicks the popup's cancel button.
I'd really appreciate it if someone could help me out with this. I tried a bunch of things but nothing works the way it is currently implemented.
Thanks -
7. Re: modal panel as confirmation box?
laguiar Mar 4, 2008 1:49 PM (in response to janson12)It's possible to after the call oncomplete="Richfaces.hideModalPanel('id')", I redirect to another page?
Like an exit confirm dialog. -
8. Re: modal panel as confirmation box?
janson12 Mar 5, 2008 12:02 PM (in response to janson12)@ massep: I'd split the whole process into a confirm and an action part. The confirm part only calls the richfaces showpanel function (via onclick) whereas the panel itself calls the respective action or just vanishes. if you have anything on the screen that is influenced by your action i'd recommend the <a4j:commandButton> as you can reRender the affected area on your screen (looks way cooler ;)
@laguiar: action="targetpage" on your commandButton and a corresponding navigation rule in your faces-conf is just one way to do that.