[JBoss JIRA] (RF-12831) <rich:validator/> performs ajax validation without updating underlying model field
by Kamil Roman (JIRA)
[ https://issues.jboss.org/browse/RF-12831?page=com.atlassian.jira.plugin.s... ]
Kamil Roman updated RF-12831:
-----------------------------
Workaround Description: Apply the value passed to the validation method to model manually, however it requires boilerplate code, is forget-error-prone and is not type-safe.
Workaround: Workaround Exists
Description:
Not sure if it's a bug or a feature, but field annotated with {code}<rich:validator/>{code} with a validation method set with {code}validator{code} attribute gets validated without updating the underlying model field. My code is something like this:
{code:title=Model.java}
public class Model {
//...
public Date getValidFrom() {/*...*/}
public Date getValidTo() {/*...*/}
}
{code}
{code:title=ModelValidator.java}
public class ModelValidator{
private Model model;
public boolean isValidToAfterValidFrom() {
return model.getValidTo().after(model.getValidFrom());
}
}
{code}
{code:title=model_form.xml}
<c:set var="model" value="#{ModelBean.model}"/>
<h:outputLabel value="#{labels.getLabel('valid_from')}" for="validFrom" />
<rich:calendar value="#{model.validFrom}" id="validFrom" >
<rich:validator/>
</rich:calendar>
<rich:message for="validFrom"/>
<h:outputLabel value="#{labels.getLabel('valid_to')}" for="validTo" />
<rich:calendar value="#{model.validTo}" id="validTo" validator="#{modelBean.validateValidTo}">
<rich:validator event="inputblur"/>
</rich:calendar>
<rich:message for="validTo"/>
{code}
{code:title=ModelBean.java}
public class ModelBean {
public Model getModel() {/*..*/}
private ModelValidator validator;
//...
public validateValidTo(FacesContext context, UIComponent toValidate, Object value) {
if(!validator.isValidToAfterValidFrom()) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, labelBean.getLabel("valid.to.not.after.valid.from.error"), null);
throw new ValidatorException(message);
}
{code}
The getModel() method returns the same Model instance as is used by the ModelValidator in ModelBean.
Now, the testcase is:
1. User selects validTo earlier than ValidFrom (on a valid Model instance)
2. Validation passes as the underlying model value is not updated (validator refers to the same Model instance as ModelBean)
3. User submits the form.
4. System displays error message as server-side validation on submit is performed after applying request values.
5. User corrects the value in validTo field.
6. System still displays error message as validation fails, because the new value is not applied to the model (model holds the invalid value applied during failed submit).
If this is not a bug, but a feature, it would be great if you included this behaviour in the docs!
was:
Not sure if it's a bug or a feature, but field annotated with {code}<rich:validator/>{code} with a validation method set with {code}validator{code} attribute gets validated without updating the underlying model field. My code is something like this:
{code title=Model.java}
public class Model {
//...
public Date getValidFrom() {/*...*/}
public Date getValidTo() {/*...*/}
}
{code}
{code title=ModelValidator.java}
public class ModelValidator{
private Model model;
public boolean isValidToAfterValidFrom() {
return model.getValidTo().after(model.getValidFrom());
}
}
{code}
{code title=model_form.xml}
<c:set var="model" value="#{ModelBean.model}"/>
<h:outputLabel value="#{labels.getLabel('valid_from')}" for="validFrom" />
<rich:calendar value="#{model.validFrom}" id="validFrom" >
<rich:validator/>
</rich:calendar>
<rich:message for="validFrom"/>
<h:outputLabel value="#{labels.getLabel('valid_to')}" for="validTo" />
<rich:calendar value="#{model.validTo}" id="validTo" validator="#{modelBean.validateValidTo}">
<rich:validator event="inputblur"/>
</rich:calendar>
<rich:message for="validTo"/>
{code}
{code title=ModelBean.java}
public class ModelBean {
public Model getModel() {/*..*/}
private ModelValidator validator;
//...
public validateValidTo(FacesContext context, UIComponent toValidate, Object value) {
if(!validator.isValidToAfterValidFrom()) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, labelBean.getLabel("valid.to.not.after.valid.from.error"), null);
throw new ValidatorException(message);
}
{code}
Now, the testcase is:
1. User selects validTo earlier than ValidFrom (on a valid Model instance)
2. Validation passes as the underlying model value is not updated (validator refers to the same Model instance as ModelBean)
3. User submits the form.
4. System displays error message as server-side validation on submit is performed after applying request values.
5. User corrects the value in validTo field.
6. System still displays error message as validation fails, because the new value is not applied to the model (model holds the invalid value applied during failed submit).
A (rather) simple workaround is to apply the value passed to the validation method to model manually, however it requires boilerplate code, is forget-error-prone and is not type-safe.
If this is not a bug, but a feature, it would be great if you included this behaviour in the docs!
> <rich:validator/> performs ajax validation without updating underlying model field
> ----------------------------------------------------------------------------------
>
> Key: RF-12831
> URL: https://issues.jboss.org/browse/RF-12831
> Project: RichFaces
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Affects Versions: 4.3.0.Final
> Environment: JBoss eap 6.0.0, Win 7
> Reporter: Kamil Roman
> Priority: Minor
>
> Not sure if it's a bug or a feature, but field annotated with {code}<rich:validator/>{code} with a validation method set with {code}validator{code} attribute gets validated without updating the underlying model field. My code is something like this:
> {code:title=Model.java}
> public class Model {
> //...
> public Date getValidFrom() {/*...*/}
> public Date getValidTo() {/*...*/}
> }
> {code}
> {code:title=ModelValidator.java}
> public class ModelValidator{
> private Model model;
> public boolean isValidToAfterValidFrom() {
> return model.getValidTo().after(model.getValidFrom());
> }
> }
> {code}
> {code:title=model_form.xml}
> <c:set var="model" value="#{ModelBean.model}"/>
> <h:outputLabel value="#{labels.getLabel('valid_from')}" for="validFrom" />
> <rich:calendar value="#{model.validFrom}" id="validFrom" >
> <rich:validator/>
> </rich:calendar>
> <rich:message for="validFrom"/>
>
> <h:outputLabel value="#{labels.getLabel('valid_to')}" for="validTo" />
> <rich:calendar value="#{model.validTo}" id="validTo" validator="#{modelBean.validateValidTo}">
> <rich:validator event="inputblur"/>
> </rich:calendar>
> <rich:message for="validTo"/>
> {code}
> {code:title=ModelBean.java}
> public class ModelBean {
> public Model getModel() {/*..*/}
> private ModelValidator validator;
> //...
> public validateValidTo(FacesContext context, UIComponent toValidate, Object value) {
> if(!validator.isValidToAfterValidFrom()) {
> FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, labelBean.getLabel("valid.to.not.after.valid.from.error"), null);
>
> throw new ValidatorException(message);
> }
> {code}
> The getModel() method returns the same Model instance as is used by the ModelValidator in ModelBean.
> Now, the testcase is:
> 1. User selects validTo earlier than ValidFrom (on a valid Model instance)
> 2. Validation passes as the underlying model value is not updated (validator refers to the same Model instance as ModelBean)
> 3. User submits the form.
> 4. System displays error message as server-side validation on submit is performed after applying request values.
> 5. User corrects the value in validTo field.
> 6. System still displays error message as validation fails, because the new value is not applied to the model (model holds the invalid value applied during failed submit).
> If this is not a bug, but a feature, it would be great if you included this behaviour in the docs!
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 12 months
[JBoss JIRA] (RF-12831) <rich:validator/> performs ajax validation without updating underlying model field
by Kamil Roman (JIRA)
Kamil Roman created RF-12831:
--------------------------------
Summary: <rich:validator/> performs ajax validation without updating underlying model field
Key: RF-12831
URL: https://issues.jboss.org/browse/RF-12831
Project: RichFaces
Issue Type: Bug
Security Level: Public (Everyone can see)
Affects Versions: 4.3.0.Final
Environment: JBoss eap 6.0.0, Win 7
Reporter: Kamil Roman
Priority: Minor
Not sure if it's a bug or a feature, but field annotated with {code}<rich:validator/>{code} with a validation method set with {code}validator{code} attribute gets validated without updating the underlying model field. My code is something like this:
{code title=Model.java}
public class Model {
//...
public Date getValidFrom() {/*...*/}
public Date getValidTo() {/*...*/}
}
{code}
{code title=ModelValidator.java}
public class ModelValidator{
private Model model;
public boolean isValidToAfterValidFrom() {
return model.getValidTo().after(model.getValidFrom());
}
}
{code}
{code title=model_form.xml}
<c:set var="model" value="#{ModelBean.model}"/>
<h:outputLabel value="#{labels.getLabel('valid_from')}" for="validFrom" />
<rich:calendar value="#{model.validFrom}" id="validFrom" >
<rich:validator/>
</rich:calendar>
<rich:message for="validFrom"/>
<h:outputLabel value="#{labels.getLabel('valid_to')}" for="validTo" />
<rich:calendar value="#{model.validTo}" id="validTo" validator="#{modelBean.validateValidTo}">
<rich:validator event="inputblur"/>
</rich:calendar>
<rich:message for="validTo"/>
{code}
{code title=ModelBean.java}
public class ModelBean {
public Model getModel() {/*..*/}
private ModelValidator validator;
//...
public validateValidTo(FacesContext context, UIComponent toValidate, Object value) {
if(!validator.isValidToAfterValidFrom()) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, labelBean.getLabel("valid.to.not.after.valid.from.error"), null);
throw new ValidatorException(message);
}
{code}
Now, the testcase is:
1. User selects validTo earlier than ValidFrom (on a valid Model instance)
2. Validation passes as the underlying model value is not updated (validator refers to the same Model instance as ModelBean)
3. User submits the form.
4. System displays error message as server-side validation on submit is performed after applying request values.
5. User corrects the value in validTo field.
6. System still displays error message as validation fails, because the new value is not applied to the model (model holds the invalid value applied during failed submit).
A (rather) simple workaround is to apply the value passed to the validation method to model manually, however it requires boilerplate code, is forget-error-prone and is not type-safe.
If this is not a bug, but a feature, it would be great if you included this behaviour in the docs!
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 12 months
[JBoss JIRA] (RF-12827) Showcase - switching among dynamically created panels, tabs cease to function
by RH Bugzilla Integration (JIRA)
[ https://issues.jboss.org/browse/RF-12827?page=com.atlassian.jira.plugin.s... ]
RH Bugzilla Integration commented on RF-12827:
----------------------------------------------
Karel Piwko <kpiwko(a)redhat.com> made a comment on [bug 912674|https://bugzilla.redhat.com/show_bug.cgi?id=912674]
I'm lowering severity to medium. For Brian's comments it seems that this is only a bug in the example itself. Marek, would you be able to cherry pick the fix for CR1?
> Showcase - switching among dynamically created panels, tabs cease to function
> -----------------------------------------------------------------------------
>
> Key: RF-12827
> URL: https://issues.jboss.org/browse/RF-12827
> Project: RichFaces
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: component-panels-layout-themes, showcase
> Affects Versions: 4.3.0.Final
> Reporter: Juraj Húska
> Assignee: Brian Leathem
> Fix For: 4.3.2
>
>
> Dynamically Tabs, Panels can not be switched after some working with them.
> It seems that they cease to function when the tab which was active after the form submission is revisited. It is working again after next form submission, but only till the new active tab is not clicked again.
> The following components are affected: rich:togglePanel, rich:tabPanel, rich:accordion.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 12 months
[JBoss JIRA] (RF-12827) Showcase - switching among dynamically created panels, tabs cease to function
by Brian Leathem (JIRA)
[ https://issues.jboss.org/browse/RF-12827?page=com.atlassian.jira.plugin.s... ]
Brian Leathem resolved RF-12827.
--------------------------------
Assignee: Brian Leathem
Resolution: Done
Removed the nested tab from within the repeating components
> Showcase - switching among dynamically created panels, tabs cease to function
> -----------------------------------------------------------------------------
>
> Key: RF-12827
> URL: https://issues.jboss.org/browse/RF-12827
> Project: RichFaces
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: component-panels-layout-themes, showcase
> Affects Versions: 4.3.0.Final
> Reporter: Juraj Húska
> Assignee: Brian Leathem
> Fix For: 4.3.2
>
>
> Dynamically Tabs, Panels can not be switched after some working with them.
> It seems that they cease to function when the tab which was active after the form submission is revisited. It is working again after next form submission, but only till the new active tab is not clicked again.
> The following components are affected: rich:togglePanel, rich:tabPanel, rich:accordion.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 12 months
[JBoss JIRA] (RF-12765) Rich:tabPanel not possible to switch tabs when only dynamic tabs are present
by Brian Leathem (JIRA)
[ https://issues.jboss.org/browse/RF-12765?page=com.atlassian.jira.plugin.s... ]
Brian Leathem resolved RF-12765.
--------------------------------
Resolution: Done
In RF-12827 I updated the showcase samples to not use nested forms, in accordance with the html specification: http://www.w3.org/TR/html5/forms.html#the-form-element
> Rich:tabPanel not possible to switch tabs when only dynamic tabs are present
> ----------------------------------------------------------------------------
>
> Key: RF-12765
> URL: https://issues.jboss.org/browse/RF-12765
> Project: RichFaces
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: component-output
> Affects Versions: 4.3.0.M3, 4.3.0.CR2, 4.3.0.Final, 4.3.1
> Environment: Linux, windows any browser Chrom, Mozilla
> Reporter: Tali Han
> Assignee: Lukáš Fryč
> Fix For: 4.3.2
>
> Original Estimate: 2 hours
> Remaining Estimate: 2 hours
>
> Rih:Tab panel functionality is broken.
> If you have dynamically generated tabs, you'll be able to switch from first to last, and then to first, but you'll not be able to switch to any other tab again.
> Remove from example that comes with richfaces distribution first static tab for dynamic tabs and you'll be able to reproduce this behaviour.
> richfaces/tabPanel/samples/dynamic-sample.xhtml
> {code}
> <rich:tabPanel activeItem="#{dynamicPanelBean.activeTab}">
> <ui:remove>
> <rich:tab header="Static">
> <p>This tab is static one.</p>
>
> <p>All of the following tabs are dynamically generated using <b>a4j:repeat</b>.</p>
> </rich:tab>
> </ui:remove>
> <a4j:repeat value="#{skinBean.skins}" var="skinName">
>
> <rich:tab header="#{skinName}" name="#{skinName}">
> <f:facet name="header">#{skinName}</f:facet>
> <i> All the controls below are just standard JSF components skinned with RichFaces: </i>
> <hr />
> <h:form>
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 12 months
[JBoss JIRA] (RF-12827) Showcase - switching among dynamically created panels, tabs cease to function
by Brian Leathem (JIRA)
[ https://issues.jboss.org/browse/RF-12827?page=com.atlassian.jira.plugin.s... ]
Brian Leathem commented on RF-12827:
------------------------------------
In RF-12765 I noticed the same behaviour only occurred with a nested form. Looking at the showcase samples reported here, I see they also use nested forms. Nesting forms in HTML is forbidden (http://www.w3.org/TR/html5/forms.html#the-form-element), and as such is in JSF as well. I will try removing the inner form element.
> Showcase - switching among dynamically created panels, tabs cease to function
> -----------------------------------------------------------------------------
>
> Key: RF-12827
> URL: https://issues.jboss.org/browse/RF-12827
> Project: RichFaces
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: component-panels-layout-themes, showcase
> Affects Versions: 4.3.0.Final
> Reporter: Juraj Húska
> Fix For: 4.3.2
>
>
> Dynamically Tabs, Panels can not be switched after some working with them.
> It seems that they cease to function when the tab which was active after the form submission is revisited. It is working again after next form submission, but only till the new active tab is not clicked again.
> The following components are affected: rich:togglePanel, rich:tabPanel, rich:accordion.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 12 months
[JBoss JIRA] (RF-12765) Rich:tabPanel not possible to switch tabs when only dynamic tabs are present
by Brian Leathem (JIRA)
[ https://issues.jboss.org/browse/RF-12765?page=com.atlassian.jira.plugin.s... ]
Brian Leathem commented on RF-12765:
------------------------------------
A github view showing the mojarra changes between the 2.1.12 and 2.1.13 versions:
https://github.com/jboss/mojarra/compare/2.1.12-jbossorg-1...2.1.13-jboss...
> Rich:tabPanel not possible to switch tabs when only dynamic tabs are present
> ----------------------------------------------------------------------------
>
> Key: RF-12765
> URL: https://issues.jboss.org/browse/RF-12765
> Project: RichFaces
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: component-output
> Affects Versions: 4.3.0.M3, 4.3.0.CR2, 4.3.0.Final, 4.3.1
> Environment: Linux, windows any browser Chrom, Mozilla
> Reporter: Tali Han
> Assignee: Lukáš Fryč
> Fix For: 4.3.2
>
> Original Estimate: 2 hours
> Remaining Estimate: 2 hours
>
> Rih:Tab panel functionality is broken.
> If you have dynamically generated tabs, you'll be able to switch from first to last, and then to first, but you'll not be able to switch to any other tab again.
> Remove from example that comes with richfaces distribution first static tab for dynamic tabs and you'll be able to reproduce this behaviour.
> richfaces/tabPanel/samples/dynamic-sample.xhtml
> {code}
> <rich:tabPanel activeItem="#{dynamicPanelBean.activeTab}">
> <ui:remove>
> <rich:tab header="Static">
> <p>This tab is static one.</p>
>
> <p>All of the following tabs are dynamically generated using <b>a4j:repeat</b>.</p>
> </rich:tab>
> </ui:remove>
> <a4j:repeat value="#{skinBean.skins}" var="skinName">
>
> <rich:tab header="#{skinName}" name="#{skinName}">
> <f:facet name="header">#{skinName}</f:facet>
> <i> All the controls below are just standard JSF components skinned with RichFaces: </i>
> <hr />
> <h:form>
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 12 months
[JBoss JIRA] (RF-12765) Rich:tabPanel not possible to switch tabs when only dynamic tabs are present
by Brian Leathem (JIRA)
[ https://issues.jboss.org/browse/RF-12765?page=com.atlassian.jira.plugin.s... ]
Brian Leathem commented on RF-12765:
------------------------------------
I updated the test to fail with tomcat 6. I noticed two things:
1) The failure only occurs when the dynamically created tab contains a _<h:form>_ element
2) The failure only occurs when the Mojarra version >= 2.1.13 (similarly to RF-12827)
> Rich:tabPanel not possible to switch tabs when only dynamic tabs are present
> ----------------------------------------------------------------------------
>
> Key: RF-12765
> URL: https://issues.jboss.org/browse/RF-12765
> Project: RichFaces
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: component-output
> Affects Versions: 4.3.0.M3, 4.3.0.CR2, 4.3.0.Final, 4.3.1
> Environment: Linux, windows any browser Chrom, Mozilla
> Reporter: Tali Han
> Assignee: Lukáš Fryč
> Fix For: 4.3.2
>
> Original Estimate: 2 hours
> Remaining Estimate: 2 hours
>
> Rih:Tab panel functionality is broken.
> If you have dynamically generated tabs, you'll be able to switch from first to last, and then to first, but you'll not be able to switch to any other tab again.
> Remove from example that comes with richfaces distribution first static tab for dynamic tabs and you'll be able to reproduce this behaviour.
> richfaces/tabPanel/samples/dynamic-sample.xhtml
> {code}
> <rich:tabPanel activeItem="#{dynamicPanelBean.activeTab}">
> <ui:remove>
> <rich:tab header="Static">
> <p>This tab is static one.</p>
>
> <p>All of the following tabs are dynamically generated using <b>a4j:repeat</b>.</p>
> </rich:tab>
> </ui:remove>
> <a4j:repeat value="#{skinBean.skins}" var="skinName">
>
> <rich:tab header="#{skinName}" name="#{skinName}">
> <f:facet name="header">#{skinName}</f:facet>
> <i> All the controls below are just standard JSF components skinned with RichFaces: </i>
> <hr />
> <h:form>
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 12 months