Hello, the problem is solved. Thanks Udo!
The reason was that I was using MyFaces 1.2.8 in combination with tobago
1.0.30.
Since I downgrade to MyFaces 1.1.8 the validation in popups is working.
Regards Michael
Am 08.10.2010 18:30, schrieb Udo Schnurpfeil:
Hi Michael,
I've just rechecked you sample, but I can't reproduce the problem. So,
it may depends on some odd diffence of my and you environment.
Let be describe what I did:
1. svn co
https://svn.apache.org/repos/asf/myfaces/tobago/tags/tobago-1.0.30/example/demo/
demo
2. cd demo
3. edit src/main/webapp/popup-test.jsp (this is a modified version of
you sniplet, the EL to the Java code was removed)
<%@ taglib uri="http://myfaces.apache.org/tobago/component"
prefix="tc" %>
<%@ taglib uri="http://myfaces.apache.org/tobago/extension"
prefix="tx" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib tagdir="/WEB-INF/tags/layout" prefix="layout" %>
<layout:overview>
<jsp:body>
<tc:box label="Test for Popups to be open in case of an validation
error">
<f:facet name="layout">
<tc:gridLayout rows="fixed;1*"/>
</f:facet>
<tc:form>
<tc:panel>
<f:facet name="layout">
<tc:gridLayout rows="fixed" columns="fixed"/>
</f:facet>
<tc:button label="new item">
<tc:attribute name="renderedPartially" value="non_modal_popup1"/>
<f:facet name="popup">
<tc:popup width="500" height="325" id="non_modal_popup1" modal="true">
<tc:box label="create new item">
<f:facet name="layout">
<tc:gridLayout columns="1*" rows="fixed;fixed"/>
</f:facet>
<tc:cell>
<tx:in label="contact name" value="some value" required="true"/>
</tc:cell>
<tc:cell>
<tc:button width="100" label="add">
<tc:attribute name="popupClose" value="afterSubmit"/>
</tc:button>
</tc:cell>
</tc:box>
</tc:popup>
</f:facet>
</tc:button>
</tc:panel>
</tc:form>
</tc:box>
</jsp:body>
</layout:overview>
4. mvn jetty:run-exploded
5. browse: http://localhost:8080/tobago-example-demo/faces/popup-test.jsp
6. click "new item" -> popup opens
7. click "add" -> popup closes
8. click "new item" -> popup opens
9. remove the value of "contact name"
10. click "add" -> popup keeps open and the input will be colored red
Can you check, if this works the same way on your box.
Regards,
Udo
Am 04.10.10 10:59, schrieb Volker Weber:
Hi Michael,
yes we have validation in Popups, but this is a bit hack like, nothing
to show as example.
The problem is the partial rendering and the popup handling in tobago
1.0.x:
If you need validation inside a popup, you should not close the popup
via popupClose attribute, but rerender the popup content partial and,
on success, close the popup via hidden button and javascript.
something like this should work, if you set the
#{myController.closePopup} value in your newItem action.
<tc:cell>
<f:facet name="layout">
<tc:gridLayout colums="fixed;1*" />
</f:facet>
<tc:button width="100" label="add" action="#{myController.newitem}">
<tc:attribute name="popupClose" value="afterSubmit"/>
</tc:button>
<tc:text escape="false"
rendered="#{myController.closePopup}"
value="<script
type=\"text/javascript\">Tobago.submitAction('full clientId of
hiddenCloseButton');</script>" />
<f:facet name="hiddenCloseButton">
<tc:button id="hiddenCloseButton">
<tc:attribute name="popupClose" value="afterSubmit"/>
</tc:button>
</f:facet>
</tc:cell>
In tobago 1.5 this would be easier.
Regards,
Volker
2010/10/4 Michael Kakuschky<kakusc...@elbe-net.de>:
Does nobody has an working example for validation in popus?
Regards Michael
Am 29.09.2010 08:57, schrieb Michael Kakuschky:
Hello Udo, thanks for the answer but my form is already around the
tc:button which I used to open the popup. Here is a snippset of my
original
version. The popup works and the form data will processed. Only
validations
and required checks doesn't work. In case of missing or wrong data
the pop
is just closing without calling the action method of the popups submit
button. Can you show on this example what's todo or maybe wrong ?
Thanks& best regards Michael
<tc:form>
<tc:panel>
<f:facet name="layout">
<tc:gridLayout rows="fixed" columns="fixed" />
</f:facet>
<tc:button label="new item">
<tc:attribute name="renderedPartially" value="non_modal_popup1"/>
<f:facet name="popup">
<tc:popup width="500" height="325" id="non_modal_popup1" modal="true">
<tc:box label="create new item">
<f:facet name="layout">
<tc:gridLayout columns="1*" rows="fixed;fixed" />
</f:facet>
<tc:cell>
<tx:in label="contact name"
value="#{myController.itemToAdd.contact_name}"
required="true" />
</tc:cell>
<tc:cell>
<tc:button width="100" label="add" action="#{myController.newitem}">
<tc:attribute name="popupClose" value="afterSubmit"/>
</tc:button>
</tc:cell>
</tc:box>
</tc:popup>
</f:facet>
</tc:button>
</tc:panel>
</tc:form>
Am 28.09.2010 15:12, schrieb Udo Schnurpfeil:
Hello Michael,
please try to put the form outside of the command tag, which opens
the
popup. This should solve your problems.
The background is: The popup must be inside the form to consider
it was
already active.
Regards,
Udo
Am 23.09.10 22:29, schrieb Michael Kakuschky:
Hello, I have a form in a popup. Now it works fine and I add some
validators to it. I checked that they are executed and throws the
ValidatorException if the input does not match the requirements.
In case of exceptions the action behind the popup form is not
executed
but unfortunately the popup is closed without any notification
about the
wrong input. Is there a way to keep the popup open so that the
user is
informed about the wrong input?
thanks®ards Michael