我使用了伟大的omnifaces 1.7解决方法FixViewState来修复以下问题:viewstate和ViewScope在ajax render ="@ form"上丢失.解决方法似乎适用于f:ajax但不适用于a4j:ajax(richfaces).
该修复程序是否应该与开箱即用的richfaces一起使用?(richfaces版本是4.3.5)
也许是由a4j记录的相关问题:日志:
error[15:09:31.667]: [status=200] During update: javax.faces.ViewState not found
Run Code Online (Sandbox Code Playgroud)
谢谢!
我有一个RoleStatus枚举,它作为Role实体的属性映射到DB中的整数(但该部分是无关紧要的).我想提出一个List<Role>在<p:dataTable>其中一列应该有一个<h:selectOneMenu>对RoleStatus的财产Role实体.如何使用或不使用OmniFaces实现此功能?
这是枚举:
public enum RoleStatus {
ACTIVE(1, "Active"),
DISABLE(2, "Disable");
private final int intStatus;
private final String status;
private RoleStatus(int intStatus, String status) {
this.intStatus = intStatus;
this.status = status;
}
public int getIntStatus() {
return status;
}
public String getStatus() {
return status;
}
}
Run Code Online (Sandbox Code Playgroud)
这是支持bean:
@ManagedBean
@ViewScoped
public class RoleController {
private List<Role> roles;
@ManagedProperty("#{roleService}")
private IRoleService roleService;
@PostConstruct
public …Run Code Online (Sandbox Code Playgroud) 我环顾四周,无法找到解决方案.
我正在使用Omnifaces listConverter的PickList组件Primefaces.当我将物品从SOURCE移动到TARGET时.在支持bean中,我只获得新项目dualList.getTarget().
但是当我将物品从TARGET移动到SOURCE时.在支持bean中,我无法检查是否已从TARGET中删除了某个项目.
我试过dualList.getSource()- SOURCE不包含从TARGET中删除的项目.
当然,dualList.getTarget()将为空(假设没有项目从SOURCE移动到TARGET).
我的问题是如何才能在支持bean中发现某些内容已从TARGET转移到SOURCE?
以前我已经创建了一个自定义转换器,在那里,我dualList.getTarget()给了我更新的目标(即旧值+添加的新值+删除旧值).因此,我可以弄清楚哪些值被添加,删除并仍然存在.
但在使用Omnifaces listConverter时我并不了解如何实现它.
我的代码看起来像这样:
XHTML
<p:pickList id="pickList" value="#{assignBenchmarkersBean.dualUserList}"
var="users" itemLabel="#{users.username}" itemValue="#{users}" >
<o:converter converterId="omnifaces.ListConverter"
list="#{assignBenchmarkersBean.dualUserList.source}" />
</p:pickList>
<p:commandButton id="update" value="#{bundle.create}"
styleClass="redButton bigFont"
actionListener="#{assignBenchmarkersBean.update()}" />
Run Code Online (Sandbox Code Playgroud)
豆
public void update(){
try{
prepareRemoveOldAndAddNewUsersList();
/**some other code **/
}catch(Exception e){
FacesMsg.error(ErrorMessage.UPDATE.getValue(), e);
} …Run Code Online (Sandbox Code Playgroud) 我米试图从它返回一个托管bean方法显示的图像byte[]与<o:graphicImage>使用omnifaces我部署omnifaces 2.1在WEB_INF/lib
这里是我的代码
注册.java
public byte[] getImage() throws IOException{
return Utils.toByteArray(Faces.getResourceAsStream("/resources/images/loader.gif"));
}
Run Code Online (Sandbox Code Playgroud)
主页.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 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:o="http://omnifaces.org/ui">
<h:head>
<h:outputStylesheet library="css" name="style.css"></h:outputStylesheet>
<style>
.center {
align: center;
}
</style>
</h:head>
<h:body>
<h:form>
<table style="float:right;margin-top:5px;">
<tr><td><h:commandLink action="/user/second.xhtml" style="float:right;">Second page</h:commandLink></td>
<td><h:commandLink action="#{login.logout}" style="float:right;">Logout</h:commandLink></td></tr>
</table>
</h:form>
<h:form>
<div style="margin: auto;">
<h:messages globalOnly="true" infoStyle="display:none" styleClass="error" style="list-style-type:none;"/>
<h:messages globalOnly="true" errorStyle="display:none" styleClass="green" style="list-style-type:none;"/>
<h4 align="center">Welcome to JSF #{login.username} Dude</h4>
<h3 align="center">User Profile</h3> …Run Code Online (Sandbox Code Playgroud)