You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by wo...@pta.de on 2008/05/02 17:52:07 UTC
Feasible without much effort to use panelPopup to recreate the JS confirm
window?
Hi,
Wondering if sth. like
<tr:commandButton
rendered="#{identity.hasPrivilegeUpdate()}"
id="vehicleSpeichern"
actionListener="#{TC1302.exit}"
onclick="return
confirm('#{messages['ask_if_really_save']}')" />
would be possible with panelPopup. I mean, just to get better looks as the
JS confirm really does not have much appeal.. ;)
So in theory I would think of
onclick="TrPanelPopup.show(..):.."
but my knowledge on the Trinidad JS seems somewhat limited any links to
further doc much appreciated.. ;)
Already done it? Or any other suggestions?
Thanks
Wolfgang
Re: Feasible without much effort to use panelPopup to recreate the JS confirm window?
Posted by Andrew Robinson <an...@gmail.com>.
I can't recommend a way to do it at the moment, but I can tell you to
never use return from a component JavaScript. Use "if
(!confirm('blah')) return false;". That way renderer injected JS that
appends to the event is still run when true.
On Fri, May 2, 2008 at 9:52 AM, <wo...@pta.de> wrote:
>
> Hi,
>
> Wondering if sth. like
>
> <tr:commandButton
> rendered="#{identity.hasPrivilegeUpdate()}"
> id="vehicleSpeichern"
> actionListener="#{TC1302.exit}"
> onclick="return
> confirm('#{messages['ask_if_really_save']}')" />
>
> would be possible with panelPopup. I mean, just to get better looks as the
> JS confirm really does not have much appeal.. ;)
>
> So in theory I would think of
>
> onclick="TrPanelPopup.show(..):.."
>
> but my knowledge on the Trinidad JS seems somewhat limited any links to
> further doc much appreciated.. ;)
>
> Already done it? Or any other suggestions?
>
> Thanks
> Wolfgang
>
>
Re: Feasible without much effort to use panelPopup to recreate the JS confirm window?
Posted by Richard Yee <ri...@gmail.com>.
Wolfgang,
I would suggest using the trinidad dialog framework. To do this you would
need to do the following:
1) create a page for your dialog. this would be like something like this:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="1.2"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:tr="http://myfaces.apache.org/trinidad">
<jsp:directive.page contentType="text/html;charset=utf-8"/>
<f:view>
<tr:document title="Save Dialog">
<f:loadBundle basename="com.somecompany.project.view.resources.messages"
var="bundle"/>
<tr:form>
<tr:panelPage>
<f:facet name="branding">
<tr:outputLabel value="Save Dialog"/>
</f:facet>
<tr:panelFormLayout rows="3" >
<tr:panelBox inlineStyle="width:500px;">
<tr:outputText value="#{bundle.save_msg}"/>
</tr:panelBox>
<tr:panelHorizontalLayout>
<tr:commandButton text="Ok"
action="#{saveDialogBacking.handleDialogOkButton}"/>
<tr:commandButton text="Cancel" immediate="true"
action="#{saveDialogBacking.handleDialogCancelButton}"/>
</tr:panelHorizontalLayout>
</tr:panelFormLayout>
</tr:panelPage>
</tr:form>
</tr:document>
</f:view>
</jsp:root>
2) in faces config put a navigation case in for the dialog that has a
from-outcome that starts with "dialog:
<navigation-case>
<from-outcome>dialog:saveDialog</from-outcome>
<to-view-id>/dialogs/common/saveDialog.jspx</to-view-id>
</navigation-case>
3) add the useWindow="true" and the returnListener attributes to the
commandButton tag.
4) add this to your web.xml to enable lightweight dialogs
<context-param>
<param-name>org.apache.myfaces.trinidad.ENABLE_LIGHTWEIGHT_DIALOGS</param-name>
<param-value>true</param-value>
</context-param>
5) add an action attribute with a method binding to an action handler
method. This method is going to return dialog:saveDialog" if the user has
made any changes or the next view id if they haven't.
6) Add a dialog return listener to your backing bean
/**
* cancelDialogListener - a returnListener for the save changes
* dialog.
*
* @param evt The ReturnEvent from the dialog.
*/
public void cancelDialogListener(ReturnEvent evt) {
String returnedValue = (String)evt.getReturnValue();
if ("Ok".equals(returnedValue)) {
saveChanges();
}
/* navigate user to new viewId */
FacesContext context = FacesContext.getCurrentInstance();
context.getApplication().getNavigationHandler().handleNavigation(context,
null,
"the_next_view_id");
}
7) The SaveDialogBacking class just needs these two methods:
/**
* handleDialogOkButton - controls page navigation from dialog
* when user click OK button.
* @return null
*/
public String handleDialogOkButton() {
RequestContext.getCurrentInstance().returnFromDialog("Ok", null);
return null;
}
/**
* handleDialogCancelButton - controls page navigation from dialog
* when user clicks CANCEL button
* @return null
*/
public String handleDialogCancelButton() {
RequestContext.getCurrentInstance().returnFromDialog("Cancel", null);
return null;
}
I think this is all you need to do. Let me know if you have any questions.
-Richard
On 5/2/08, wolfgang.toepfer@pta.de <wo...@pta.de> wrote:
>
>
> Hi,
>
> Wondering if sth. like
>
> <tr:commandButton
> rendered="#{identity.hasPrivilegeUpdate()}"
> id="vehicleSpeichern"
> actionListener="#{TC1302.exit}"
> onclick="return
> confirm('#{messages['ask_if_really_save']}')" />
>
> would be possible with panelPopup. I mean, just to get better looks as the
> JS confirm really does not have much appeal.. ;)
>
> So in theory I would think of
>
> onclick="TrPanelPopup.show(..):.."
>
> but my knowledge on the Trinidad JS seems somewhat limited any links to
> further doc much appreciated.. ;)
>
> Already done it? Or any other suggestions?
>
> Thanks
> Wolfgang
>
>