我的问题是,在我在第一页上选择了几个项目后,如果我分页到另一个页面并返回,我的初始选择不会显示.我试图实现SelectableDataModel以及使用rowKey属性,但问题仍然存在.
这是我的测试bean:
@ManagedBean
@ViewScoped
public class MrBean {
private List<Item> chosenItems;
private LazyDataModel lazyModel;
@PostConstruct
public void prepareTest() {
this.lazyModel = new LazyItemDataModel();
}
public void countItems() {
System.out.println("TEST 3: chosenItems's size: " + chosenItems.size());
}
private class LazyItemDataModel extends LazyDataModel<Item> implements SelectableDataModel<Item> {
@Override
public Item getRowData(String rowKey) {
System.out.println("TEST 1: getRowData");
Iterator<Item> iter = ((List<Item>) this.getWrappedData()).iterator();
while (iter.hasNext()) {
Item item = iter.next();
if (item.getId().equals(rowKey)) {
return item;
}
}
return null;
}
@Override …Run Code Online (Sandbox Code Playgroud) 当我还是用PrimeFaces V2.2.1,我能键入Unicode输入诸如与PrimeFaces输入组件中国如<p:inputText>和<p:editor>,并检索在管理bean方法好形状的输入.
但是,在我升级到PrimeFaces v3.1.1后,所有这些字符都变成了Mojibake或问号.只有拉丁语输入才能正常,中文,阿拉伯语,希伯来语,西里尔语等字符会变得格格不入.
这是怎么造成的,我该如何解决?
我很感激有人可以帮助我解决以下问题:
目前,我正在使用PayPal来实施我的付款流程.但是,我对PayPal为Java提供的过时API感到满意.我已经google了一段时间,我在几篇文章中看到了许多替代品,例如:
如果你能就这些系统的优缺点给我一些意见,我将非常感激.此外,根据您的经验,请告诉我您认为哪些API具有适合Java开发人员的API.
在我的.xhtml页面中,我有以下表格:
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
template="./../template/CustomerTemplate.xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.prime.com.tr/ui">
<ui:define name="formContent">
<h:form>
<p:dataGrid var="item" value="#{mrBean.items}" columns="3">
<p:column>
<p:panel header="#{item.name}">
<h:panelGrid columns="1" style="width:100%">
...
<h:commandButton value="Add To Cart" actionListener="#{cartBean.addItem(item.id)}" />
...
</h:panelGrid>
</p:panel>
</p:column>
</p:dataGrid>
</h:form>
</ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
CustomerTemplate.xhtml是:
<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:p="http://primefaces.prime.com.tr/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
... // import css, js files
</h:head>
<h:body>
... // Other things on the page
<div class="grid_9 content">
<ui:insert name="contentTitle"></ui:insert>
<ui:insert name="formContent"></ui:insert>
</div>
...
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我的ManagedBean:
@ManagedBean
@ViewScoped
public class MrBean { …Run Code Online (Sandbox Code Playgroud) 在我的公司,我们使用 Spring Boot 来实现后端 API,并使用 React 来实现前端,包括 Web 界面和 Android/iOS 应用程序。
由于我们的产品是企业软件,客户实际上必须付费才能获得最新的后端 API 来部署在自己的服务器上。但是,我们的移动应用程序会在 App Store 上定期更新。这会导致最终用户设备上的移动应用程序可能是较新版本,而客户计算机上的后端 API 是较旧版本的情况。我们计划向后支持最多 3 个次要版本,这意味着 FE 5.4 将支持最多后端 5.2。
后端确实有一个端点来返回当前版本号。然而,当我们添加新功能并可能在后端 API 中引入重大更改时,我对我们的前端实现如何保持与旧 API 版本的向后兼容性有点一无所知。
我完全理解这个问题可能没有任何完美的解决方案。我希望如果你经历过这种痛苦,你可以分享你的经历,包括你尝试过的事情、你采取的最终方法以及需要注意的潜在陷阱。
我确信我自己和其他遇到这个问题的人都会非常感激:)。
在文件中aPage.xhtml,我有以下几行:
<ui:include rendered="#{not empty param.target}" src="#{param.target}.html" />
<ui:include rendered="#{empty param.target}" src="About.html" />
Run Code Online (Sandbox Code Playgroud)
通过以上的线路,我预计,当我去http://localhost:8080/beta/aPage.xhtml时,页面About.html会因为已有的param.targetIS null.但是,GlassFish抛出了以下异常:
java.io.FileNotFoundException: http://localhost:8080/beta/.html
Run Code Online (Sandbox Code Playgroud)
不知何故,param.target不被认为是null.
此外,我确实尝试使用==和!=运算符如下:
<ui:include rendered="#{param.target != null}" src="#{param.target}.html" />
<ui:include rendered="#{param.target == null}" src="About.html" />
Run Code Online (Sandbox Code Playgroud)
有趣的是,这一次,在GlassFish的控制台上,我没有看到任何异常抛出.但是,在浏览器上,仍会显示错误页面,但有例外java.io.FileNotFoundException.
如果你能告诉我为什么会这样,我应该做些什么来避免它,我将非常感激.
更新:
感谢Joop Eggen的提示,我终于用以下几行解决了这个问题:
<ui:param name="noTarget" value="About.html" />
<ui:param name="hasTarget" value="#{param.target}.html" />
<ui:include src="#{empty param.target? noTarget : hasTarget}" />
Run Code Online (Sandbox Code Playgroud)
最好的祝福
创建按钮时,ui-corner-all始终应用该类.我尝试了以下方法:
<p:commandButton id="like" styleClass="ui-corner-right" />
Run Code Online (Sandbox Code Playgroud)
但它不起作用.在Firebug的,我看到都ui-corner-all和ui-corner-right:
<div id="form1:like" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left ui-corner-right">
Run Code Online (Sandbox Code Playgroud)
更新1:
继从JMelnik提示,我终于成功地改变风格ui-corner-all,以ui-corner-right加入下面的脚本:
<style type="text/css">
#myForm\:likeButton .ui-corner-all {
border-radius: 6px 0px 0px 6px !important;
}
</style>
Run Code Online (Sandbox Code Playgroud)
并将<p:commandButton>内部包装<h:panelGroup>如下:
<h:form id="myForm">
<h:panelGroup id="likeButton">
<p:commandButton />
<h:panelGroup>
</h:form>
Run Code Online (Sandbox Code Playgroud)
更新2:
感谢BalusC的建议,以下解决方案应该更好:
<style type="text/css">
.likeButton .ui-corner-all {
border-radius: 6px 0px 0px 6px !important;
}
</style>
<h:panelGroup styleClass="likeButton">
<p:commandButton />
<h:panelGroup>
Run Code Online (Sandbox Code Playgroud)
最好的祝福,
在我的申请中,我有以下内容<p:dataTable>:

第二列的标题占用太多空格.因此,我想在Number of&之间放置一个换行符,Sessions并且还要垂直对齐表格的标题.我试图减少列的宽度,但它不会自动导致换行.
此外,由于从l10n.properties文件中检索了标题名称,我还尝试将其设置为,Number of /n Sessions但是/n作为普通字符串打印出来.
更新:我也尝试将属性设置为Number of <br/> Sessions.但是,在生成的HTML代码中,<br/>消失了,表格看起来与上面完全相同.
如果你能给我一个建议,我将非常感激.
最好的祝福,
在我的应用程序中,我使用 JSF 和 Java Web 服务。当我的任何 Web 服务函数返回一个null值时,它始终表示为“null”字符串。因此,我无法使用 EL 表达式来#{empty object}测试null值或空字符串。
我想问是否有一种方法可以进行配置,使 Java Web Services 将返回null值作为空字符串,或者 JSF/EL 可以将“null”字符串理解为null值。
java ×6
jsf-2 ×6
primefaces ×4
css ×2
api ×1
datatable ×1
ejb ×1
el ×1
exception ×1
integration ×1
jsf ×1
lazy-loading ×1
line-breaks ×1
login ×1
mojibake ×1
null ×1
pagination ×1
param ×1
react-native ×1
roles ×1
scope ×1
security ×1
spring ×1
string ×1
styling ×1
unicode ×1
versioning ×1
web-services ×1