f:ajax侦听器不重定向页面,而p:ajax工作正常
我在一个表单中有两个下拉菜单,在更改第一个菜单上的值时,第二个菜单被刷新(AJAX),然后我可以使用一个按钮提交表单,该按钮在视图范围的bean中执行一些操作,完成后重定向到成功页面,我面临一个我无法解决的问题 也就是说,当我使用f:ajax侦听器不重定向页面,而p:ajax工作正常,ajax,jsf,redirect,primefaces,Ajax,Jsf,Redirect,Primefaces,我在一个表单中有两个下拉菜单,在更改第一个菜单上的值时,第二个菜单被刷新(AJAX),然后我可以使用一个按钮提交表单,该按钮在视图范围的bean中执行一些操作,完成后重定向到成功页面,我面临一个我无法解决的问题 也就是说,当我使用标记时: 当我在不更改菜单的情况下提交表单时,将执行该操作,并正常重定向 当我更改菜单并单击“提交”按钮时,将执行操作,但页面从未重定向 当使用标记时,它按预期工作,我已经搜索了一段时间,我想问题在于请求ajax,但我不知道具体原因,这是页面中的一个片段 XHTML 使
标记时:
标记时,它按预期工作,我已经搜索了一段时间,我想问题在于请求ajax,但我不知道具体原因,这是页面中的一个片段
XHTML
使用
标记
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="form-group arabic">
<h:selectOneMenu id="governorates" required="true"
requiredMessage="#{msgBean.getRequired()}"
styleClass="btn btn-white dropdown-toggle" style="width:100%"
value="#{propertyBean.property.propertyDetails.governate}"
converter="#{governateConverter}">
<f:selectItem itemValue="#{null}" itemLabel="اختر المحافظة"
noSelectionOption="true" />
<f:selectItems value="#{dataBean.availableGovernates}"
var="governateObj" itemValue="#{governateObj}"
itemLabel="#{governateObj.name}"/>
<f:ajax event="blur" listener="#{propertyBean.setValidCities}" render="governorate_message cities" />
</h:selectOneMenu>
<h:message id="governorate_message" for="governorates"
infoClass="help-block" errorClass="help-block error" />
</div>
</div>
答复:
HTTP/1.1 302 Found
Server: Apache-Coyote/1.1
Location: http://localhost:8080/Newgar_revamp/pages/status/success.xhtml
Content-Length: 0
Date: Fri, 20 Nov 2015 21:24:32 GMT
但是浏览器从未重定向到成功页面您没有提供
版本,但一个常见错误是使用
而不是
@ForguesR,是的,很抱歉,但是,正如您所提到的,标记的语法是正确的。浏览器控制台中的这两种情况与网络流量有什么区别?请编辑您的问题并提供非工作版本。另外,当您从
中选择值时,请确保检查javascript控制台是否存在任何错误。控制台中不会出现任何错误
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="form-group arabic">
<h:selectOneMenu id="governorates" required="true"
requiredMessage="#{msgBean.getRequired()}"
styleClass="btn btn-white dropdown-toggle" style="width:100%"
value="#{propertyBean.property.propertyDetails.governate}"
converter="#{governateConverter}">
<f:selectItem itemValue="#{null}" itemLabel="اختر المحافظة"
noSelectionOption="true" />
<f:selectItems value="#{dataBean.availableGovernates}"
var="governateObj" itemValue="#{governateObj}"
itemLabel="#{governateObj.name}"/>
<f:ajax event="blur" listener="#{propertyBean.setValidCities}" render="governorate_message cities" />
</h:selectOneMenu>
<h:message id="governorate_message" for="governorates"
infoClass="help-block" errorClass="help-block error" />
</div>
</div>
POST /Newgar_revamp/pages/add.xhtml HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Content-Length: 2207
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://localhost:8080
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryFE3725BjJXsA1xKf
Referer: http://localhost:8080/Newgar_revamp/pages/add.xhtml?propertyId=3
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6,ar;q=0.4
Cookie: JSESSIONID=B81FF21F23988CC8C98D84DA14B36F54
HTTP/1.1 302 Found
Server: Apache-Coyote/1.1
Location: http://localhost:8080/Newgar_revamp/pages/status/success.xhtml
Content-Length: 0
Date: Fri, 20 Nov 2015 21:24:32 GMT