- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用 primefaces 5.0 和 jsf 2.2.5 时遇到了问题。用一个 p:tabView
两个选项卡共享相同的 ManagedBean 和相同的对象事件 tabChange
没有按预期工作。当用户更改选项卡时,我想执行与他单击按钮相同的验证,但事件并未刷新 bean 值,但是正在发布这些值。我能够用这个简单的例子重现这个问题。
xhtml代码:
<h:body>
<div class="well">
<h:form id="testeForm">
<p:tabView id="tView">
<p:ajax event="tabChange"
process="@this"
update="@form"
listener="#{testeBean.onTabChange}" />
<p:tab id="tab1" title="tab1">
<p:inputText id="teste1"
value="#{testeBean.evento.nome}" />
<p:commandButton id="savetab1"
process="tab1"
update="@form"
actionListener="#{testeBean.saveTab1}"
value="salvarTab1">
</p:commandButton>
</p:tab>
<p:tab id="tab2" title="tab2">
<p:inputText id="teste2"
value="#{testeBean.evento.descricao}" />
<p:commandButton id="savetab2"
process="tab2"
update="@form"
actionListener="#{testeBean.saveTab2}"
value="salvarTab2">
</p:commandButton>
</p:tab>
</p:tabView>
</h:form>
</div>
</h:body>
package com.example.bean;
@ViewScoped
@ManagedBean(name = "testeBean")
@Getter
@Setter
public class TesteBean {
private Evento evento;
@PostConstruct
public void init() {
evento = new Evento();
}
public void saveTab1() {
System.out.println(evento);
}
public void saveTab2() {
System.out.println(evento);
}
public void onTabChange(TabChangeEvent evt) throws LoundScreenException {
System.out.println(evt.getTab().getId());
System.out.println(evento);
}
process="@this" process="@form" process="@all" immediate="true"
没有成功。我在这里错过了什么吗?
org.primefaces.component.api.UITabPanel
中我意识到 Primefaces 只在它的 process() 方法中处理子组件,如果它不是 ajax 请求的来源:
if(isRequestSource(context)) {
return;
}
最佳答案
尝试这个。
html
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<f:facet name="first">
<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8" />
<meta name="viewport"
content="user-scalable=no,
width=device-width,
initial-scale=1.0,
maximum-scale=1.0"/>
</f:facet>
<title>page2</title>
</h:head>
<h:body>
<h:form id="testeForm">
<p:remoteCommand name="rc"
process="@this,tView:teste1,tView:teste2"
update="tView:teste1,tView:teste2"
actionListener="#{testeBean.execute}" />
<p:tabView id="tView" onTabChange="rc()">
<p:tab id="tab1" title="tab1">
<p:inputText id="teste1"
value="#{testeBean.evento.nome}" />
<p:commandButton id="savetab1"
process="tab1"
update="@form"
actionListener="#{testeBean.saveTab1}"
value="salvarTab1">
</p:commandButton>
</p:tab>
<p:tab id="tab2" title="tab2">
<p:inputText id="teste2"
value="#{testeBean.evento.descricao}" />
<p:commandButton id="savetab2"
process="tab2"
update="@form"
actionListener="#{testeBean.saveTab2}"
value="salvarTab2">
</p:commandButton>
</p:tab>
</p:tabView>
</h:form>
</h:body>
</html>
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
/**
*
* @author Wittakarn
*/
@ViewScoped
@ManagedBean(name = "testeBean")
public class TesteBean implements Serializable{
private Evento evento;
public TesteBean(){
evento = new Evento();
}
@PostConstruct
public void init() {
}
public void saveTab1() {
System.out.println(evento.getNome());
System.out.println(evento.getDescricao());
}
public void saveTab2() {
System.out.println(evento.getNome());
System.out.println(evento.getDescricao());
}
public void execute() {
System.out.println(evento.getNome());
System.out.println(evento.getDescricao());
}
public Evento getEvento() {
return evento;
}
public void setEvento(Evento evento) {
this.evento = evento;
}
}
关于jsf - 素面 tabView 上的 tabChange 事件不会在 ManagedBean 中设置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26362345/
我尝试在选项卡更改上刷新布局,但我失败了: 主要 Activity package com.hello; import android.app.TabActivity; import android.
我需要在 TabView 中获取当前事件选项卡的标题。 TabView 由动态数量的选项卡构成,监听器附加到“tabChanged”: 问题是 onChange(TabChang
我正在使用 Primefaces 3.5 & JSF2.1 (Mojarra) 开发一个项目 我创建了一个素面 里面有两个选项卡,每个选项卡都有一个primefaces数据表
我在使用 primefaces 5.0 和 jsf 2.2.5 时遇到了问题。用一个 p:tabView 两个选项卡共享相同的 ManagedBean 和相同的对象事件 tabChange没有按预期工
我在 SupportV4 标签主机中的 fragment 有问题,它在单个标签更改期间加载了两个 fragment 。 (使用了 Tabhost;android/support/v4/app/Frag
我有一个显示一些选项卡的页面。每个选项卡都包含一个 Accordion 。 从技术上讲,我有一个 p:tabView 组件,其中包含四个 p:tab。我们将它们称为 p:tabView > p:tab
对于选项卡面板中的每个选项卡,我都有一个位于固定位置的 float 面板。当我切换标签时,我需要将相应的 float 面板带到前面。但是,tabchange 事件仅在第一次触发。单击选项卡时如何捕获此
我是一名优秀的程序员,十分优秀!