a4j ajax,Jsf RichFaces a4j:support migration to a4j:ajax

2023-05-16

问题

I have problem with converting this code from JSF 1.2 application to equivalent in JSF 2.x application

ajaxSingle="false"

immediate="true"

reRender="myForm">

value="this.value"

assignTo="#{bean.type}"

noEscape="true"/>

How this code snippet works.

Depending on selected value in #{bean.type}, my page display different fields.

When User change "type" field the whole form is rerendered, but without form validation (ajaxSingle="false", immediate="true", reRender="myForm").

I don't want to validate filds here, I just want to set new value to the #{bean.type} and rerender the page in order to show different fields (depending on #{bean.type}).

Thats why i need to manualy set #{bean.type} inside a4j:actionparam.

The nice feature about this code is that submited values in other fileds are preserved after rerendering.

I am trying to do the same thing in JSF 2.x with no success:

This:

will rerender whole form and I will lose submited values form other fields

This:

will submit, validate and rerender whole form (i want just submit without validation like in JSF 1.2)

This:

also does not work (work same as above)

So my question is how can I achive the same behavior in JSF 2.x ?

Thanks

回答1:

Thanks to Andrey comment I found solution:

value="#{bean.type}"

valueChangeListener="#{bean.typeChangeListener}"

immediate="true">

and:

public void typeChangeListener(ValueChangeEvent event) {

type = (String) event.getNewValue();

}

immediate on a4j:ajax causes that listener="#{facesContext.renderResponse}" is called during apply request values phase, and renderResponse skips validation.

immediate on h:selectOneMenu causes that valueChangeListener is also called during apply request values phase.

So I can submit whole form without validation, set type, rerender new fields based on changed type, and preserve submited values in other fileds.

来源:https://stackoverflow.com/questions/30218317/jsf-richfaces-a4jsupport-migration-to-a4jajax

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

a4j ajax,Jsf RichFaces a4j:support migration to a4j:ajax 的相关文章

随机推荐