我想,当用户选择/取消选择一些在H火灾事件变化监听器:selectManyCheckbox,如果离开它单独什么都不发生。
我的XHTML:
<!DOCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0过渡// EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< HTML LANG =EN的xmlns =http://www.w3.org/1999/xhtml
的xmlns:UI =http://java.sun.com/jsf/facelets
的xmlns:H =http://java.sun.com/jsf/html
的xmlns:F =http://java.sun.com/jsf/core
的xmlns:C =http://java.sun.com/jsp/jstl/core>
< H:头>
<链接相对=样式类型=文本/ CSS
HREF =/ juritest /资源/ CSS / style.css文件/>
<脚本类型=文/ JavaScript的
SRC =/ juritest /资源/ JS / jQuery的-1.8.2.js>< / SCRIPT>
<脚本类型=文/ JavaScript的SRC =/ juritest /资源/ JS / menu.js档案>< / SCRIPT>
< / H:头>
< H:身体GT;
<用户界面:作文模板=../../模板/ gridsTemplate.xhtml>
< UI:定义名称=内容>
...
< H:panelGroup中风格=文本对齐:左>
<小时/>
&所述; H:selectManyCheckbox
值=#{gridPopUpBean.oneQuestionUserAnswers}
布局=pageDirection>
< F:选择信息itemValue =A
itemLabel =#{gridPopUpBean.currentQuestion.a}/>
< F:选择信息itemValue =B
itemLabel =#{gridPopUpBean.currentQuestion.b}/>
< F:选择信息itemValue =C
itemLabel =#{gridPopUpBean.currentQuestion.c}/>
< F:Ajax事件=点击监听器=#{gridPopUpBean.changeListener()}/>
< / H:selectManyCheckbox>
< /小时:panelGroup中>
...
我得到一个错误说一个或多个资源具有'头'的目标,但没有头组件已在视图中定义的。我有< H:头部>不仅仅是<头,我读了,这是一个可能的问题。
和从bean的片段:
公共无效的ChangeListener(ValueChangeEvent E){
改变=真;
}
我已经试过无< F:AJAX像
< H:selectManyCheckbox
值=#{gridPopUpBean.oneQuestionUserAnswers}valueChangeListener =#{gridPopUpBean.changeListener()}的onclick =提交()
布局=pageDirection>
< F:选择信息itemValue =A
itemLabel =#{gridPopUpBean.currentQuestion.a}/>
< F:选择信息itemValue =B
itemLabel =#{gridPopUpBean.currentQuestion.b}/>
< F:选择信息itemValue =C
itemLabel =#{gridPopUpBean.currentQuestion.c}/>
< F:Ajax事件=点击监听器=#{gridPopUpBean.changeListener()}/>
< / H:selectManyCheckbox>
但没有运气...
解决方案一个或多个资源具有'头'的目标,但没有头组件已在视图中定义的我有< H:头不只是< HEAD>,我读了这是一个可能的问题。的
之外&LT任何东西; UI:组合物>
是忽略。如果你需要一个< H:头>
,它需要去主模板中的 gridsTemplate.xhtml
(或任何其父模板)。
另外,如果你没有使用一个可视化编辑器为您的XHTML文件(像Dreamweaver),那么我强烈建议停止把任何内容外< UI:组合物>
,otherwise你把自己的困惑。
< F:Ajax事件=点击监听器=#{gridPopUpBean.changeListener()}/>
公共无效的ChangeListener(ValueChangeEvent E){
你混淆 valueChangeListener
与< F:AJAX收听GT;
。该 ValueChangeEvent
的说法只适用于 valueChangeListener
的 UIInput 组件。摆脱这样的说法的。
公共无效的ChangeListener(){
无关的具体问题,您正确使用点击
(尽管你可以放心地完全忽略它),但是你的问题的标题提到变更
键,这确实是错误的事件复选框和单选按钮。
I want to fire an event change listener when the user selects / deselects something in the h:selectManyCheckbox, if it leaves it alone nothing should happen.
My xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<link rel="stylesheet" type="text/css"
href="/juritest/resources/css/style.css" />
<script type="text/javascript"
src="/juritest/resources/js/jquery-1.8.2.js"></script>
<script type="text/javascript" src="/juritest/resources/js/menu.js"></script>
</h:head>
<h:body>
<ui:composition template="../../templates/gridsTemplate.xhtml">
<ui:define name="content">
...
<h:panelGroup style="text-align: left">
<hr />
<h:selectManyCheckbox
value="#{gridPopUpBean.oneQuestionUserAnswers}"
layout="pageDirection">
<f:selectItem itemValue="a"
itemLabel="#{gridPopUpBean.currentQuestion.a}" />
<f:selectItem itemValue="b"
itemLabel="#{gridPopUpBean.currentQuestion.b}" />
<f:selectItem itemValue="c"
itemLabel="#{gridPopUpBean.currentQuestion.c}" />
<f:ajax event="click" listener="#{gridPopUpBean.changeListener()}"/>
</h:selectManyCheckbox>
</h:panelGroup>
...
I get an error saying "One or more resources have the target of 'head', but no 'head' component has been defined within the view." I have < h:head> not just < head>, I read that this was a possible problem.
And the snippet from the bean:
public void changeListener(ValueChangeEvent e) {
change = true;
}
I have tried without < f:ajax like
<h:selectManyCheckbox
value="#{gridPopUpBean.oneQuestionUserAnswers}" valueChangeListener="#{gridPopUpBean.changeListener()}" onclick="submit()"
layout="pageDirection">
<f:selectItem itemValue="a"
itemLabel="#{gridPopUpBean.currentQuestion.a}" />
<f:selectItem itemValue="b"
itemLabel="#{gridPopUpBean.currentQuestion.b}" />
<f:selectItem itemValue="c"
itemLabel="#{gridPopUpBean.currentQuestion.c}" />
<f:ajax event="click" listener="#{gridPopUpBean.changeListener()}"/>
</h:selectManyCheckbox>
but with no luck...
解决方案One or more resources have the target of 'head', but no 'head' component has been defined within the view." I have < h:head> not just < head>, I read that this was a possible problem.
Anything outside <ui:composition>
is ignored. If you need a <h:head>
, it needs to go in the master template, the gridsTemplate.xhtml
(or any of its parent templates).
Further, if you aren't using a visual editor for your XHTML files (like Dreamweaver), then I strongly recommend to stop putting any content outside <ui:composition>
, otherwise you keep confusing yourself.
<f:ajax event="click" listener="#{gridPopUpBean.changeListener()}"/>
public void changeListener(ValueChangeEvent e) {
You're confusing valueChangeListener
with <f:ajax listener>
. The ValueChangeEvent
argument is only applicable to valueChangeListener
attribute of an UIInput
component. Get rid of that argument.
public void changeListener() {
Unrelated to the concrete problem, you correctly used click
(although you could safely omit it altogether), but your question title mentions change
and that is indeed the wrong event for a checkbox and radio button.