我注意到我可以摆脱使用和的@RequestScoped 注释。@javax.enterprise.context.RequestScoped@javax.faces.bean.RequestScoped
在一种情况下,面孔版本似乎有效,而在另一种情况下,上下文版本似乎有效。
我想知道的是,哪个是首选/推荐?
我正在使用 PrimeFaces 框架,直到后来在我的开发中才意识到我可以 @ViewScoped在大多数情况下使用。
我有一个表单,用户可以在其中上传图像并裁剪它。
上传后,图片被用在croppper组件中进行裁剪
我想以固定大小显示它(如果用户的图像太大),但我无法做到这一点。
上传裁剪器组件后,以原始尺寸显示图像(因此,如果宽度为 1200px,则会填满整个屏幕)
我无法使用 css,因为 div 大小是由primefaces脚本生成的,并且我无法使用脚本,因为它在图像上传之前加载
我有一个 JSF 组件,它通过 ajax 请求通过按钮进行刷新。该组件具有按值顺序变化的图像。如果我查看网络请求,我可以看到我的浏览器没有缓存图像,而是在每次单击时请求它们。这会导致视图渲染中出现某种“弹出”现象。
我想通过缓存图像来加快刷新时间和渲染时间。我尝试在 GET 方法上使用 RequestFilter 将 Cache-Control 标头设置为“public”,但不起作用。
任何想法?
<!-- IMPLEMENTATION -->
<composite:implementation>
<h:panelGrid columns="2">
<c:choose>
<c:when test="#{cc.attrs.latencia ge cc.attrs.umbralAlto}">
<p:graphicImage value="#{resource['images:rojo.png']}"/>
</c:when>
<c:when test="#{(cc.attrs.latencia lt cc.attrs.umbralAlto) and (cc.attrs.latencia ge cc.attrs.umbralMedio)}">
<p:graphicImage value="#{resource['images:ambar.png']}"/>
</c:when>
<c:otherwise>
<p:graphicImage value="#{resource['images:verde.png']}"/>
</c:otherwise>
</c:choose>
<h:outputText value="#{cc.attrs.latencia} ms."/>
</h:panelGrid>
</composite:implementation>
Run Code Online (Sandbox Code Playgroud)
<h:body>
<h:form id="miForm">
<h:commandButton id="boton" value="Generar Latencia">
<f:ajax render="@form" event="click" listener="#{latencyBean.actualizarLatencia()}"/>
</h:commandButton>
<miscomponentes:LatencyIndicator latencia="#{latencyBean.latencia}"/>
</h:form>
</h:body>
Run Code Online (Sandbox Code Playgroud) 我正在使用 JSF 2.2 和 Primefaces 4.0。我想在调用 menuItem“userSettingMenuItem”时触发 actionListener。问题是监听器方法永远不会被调用。
这是我的 MenuBar.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!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:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<ui:composition>
<h:form>
<p:menubar styleClass="affaires"
style="position: absolute !important; bottom: 0px !important; vertical-align: bottom !important; list-style: none; width: 100%; text-align: center;">
<p:menuitem value="#{msg['navigation_home']}" url="home.xhtml" />
<p:menuitem value="Companies" url="companies.xhtml" />
<p:menuitem id="messageNumber"
value="#{taskboxMessageNumberBean.unSeenMessages} #{msg['navigation_taskbox']}"
url="taskbox.xhtml" />
<p:menuitem id="userSettingMenuItem"
value="#{loginBean.user.USER_NAME}"
url="user-settings.xhtml"
actionListener="#{userSettingBean.onClickSettingsMenuBar}"/>
<p:submenu label="#{msg['navigation_admin']}">
<p:menuitem value="Users" url="#" />
<p:menuitem value="Edit Help" url="#" />
<p:menuitem …Run Code Online (Sandbox Code Playgroud) 我在尝试删除具有外键的实体列表时遇到问题。与表配合良好的删除方法CrudRepository没有外键,但是当我尝试删除具有外键的实体列表时,它报告成功,但数据库中没有删除任何内容。deleteInBatch()两者的工作都很好。
中delete(Iterable<? extends T> itrbl)的方法有什么区别?CrudRepository and deleteInBatch(Iterable<T> itrbl)JpaRepository
我经历过这个。
任何帮助,将不胜感激
我的模型 SmsNotifyTemplate.java:
package com.viettel.pcrf.webconfig.model;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Anh Nguyen
*/
@Entity
@Table(name = "SMS_NOTIFY_TEMPLATE", catalog = "", schema = "VPCRF")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "SmsNotifyTemplate.findAll", query = "SELECT s FROM SmsNotifyTemplate …Run Code Online (Sandbox Code Playgroud) 我有一个带有表格的页面,其中有用户可以隐藏和显示的可选列。当用户选择通过表格底部的链接下载表格内容时,我想向他们发送当前显示列的内容。
为了做到这一点,我需要使用远程命令,因为常规的 commandLink 不会接受 js 参数来告诉服务器当前正在显示哪些列。
我的问题是文件没有被下载。当我调试时,我进入我的服务器方法并完全完成整个过程,当我返回浏览器时,我在 Chrome 的网络选项卡中看到文件的内容,但文件没有被下载,而是我的页面正在焕然一新。如果我在调用命令后将 return false 设置为 false,我会在 Chrome 的网络选项卡中看到该文件,并且页面不会刷新,但什么也不会发生。我尝试使用 onSuccess 或 onComplete 事件,但这些事件似乎没有按我的预期工作。
这可以使用 JSF 来完成还是我必须为此编写一个 servlet?
这是我的代码:链接
<h:commandLink value="Download data" onclick="invokeDownload();return false;" />
Run Code Online (Sandbox Code Playgroud)
调用js方法:
var invokeDownload = function() {
var columnLabels = getVisibleColumns().toString();
downloadTableData([{ "name": "columnLabels", "value": columnLabels }]);
}
Run Code Online (Sandbox Code Playgroud)
远程命令:
<p:remoteCommand name="downloadTableData" action="#{myBean.dataTable.download()}" process="@this"/>
Run Code Online (Sandbox Code Playgroud) 我想要一个UIComponent在 PrimeFaces 3.4 中通过 id 查找的方法。我已经找到了一个方法来执行此操作,但它有一个方法visitTree(在PrimeFaces 5.2中可用),该方法不适用于PrimeFaces 3.4。
请有人帮我在下面的 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:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<h:form id="form">
<p:panel id="pnl"><h:outputText value="Yahoooo...."></h:outputText></p:panel>
<p:commandButton ajax="false" value="Toggle" actionListener="#{myBean.mytoggle}"/>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
Primefaces 5.2工作方法
public UIComponent findComponent(final String id) {
FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot root = context.getViewRoot();
final UIComponent[] found = new UIComponent[1];
root.visitTree(new FullVisitContext(context), new VisitCallback() {
@Override
public VisitResult visit(VisitContext context, UIComponent component) {
if(component.getId().equals(id)){
found[0] = component;
return VisitResult.COMPLETE;
}
return VisitResult.ACCEPT;
}
});
return …Run Code Online (Sandbox Code Playgroud) 我正在尝试删除素面条形图中的网格和边框。请考虑一下新的 primefaces 图表。我用谷歌搜索了很多,只找到了primefaces旧标签的解决方案,但有新的。
<p:chart type="bar" model="#{reportServerController.horizontalBarModelG}" styleClass="chartSize" >
<p:ajax event="itemSelect" listener="#{auftragBean.itemSelectGutachten}" update="dataTableG" />
</p:chart>
Run Code Online (Sandbox Code Playgroud)
那么是否有可能从图表中删除边框和网格呢?
我正在尝试在 PrimeFaces 数据表上实现排序功能。我创建了一个模型对象列表。表的排序顺序存在问题。排序列包含整数和字符串值。当我应用默认排序机制(例如列表)时sort=#{var.id},列表是基于 ASCII 顺序进行排序的。下图是排序结果的图片。我目前使用的是 PrimeFaces v5.2.5
<p:column headerText="Code Type" sortBy="#{var.codeType}">
<h:outputText value="#{var.codeType}"/>
</p:column>
Run Code Online (Sandbox Code Playgroud)
任何人都可以指导我如何克服这个问题。
Java中是否可以获取当前的排序顺序?
以下是汽车按年份排序的示例:
<p:column headerText="Year" sortBy="#{car.year}">
<h:outputText value="#{car.year}" />
</p:column>
Run Code Online (Sandbox Code Playgroud)
通过扩展LazyDataModel<T>可以重写以下方法:
public List<T> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String,Object> filters) {
throw new UnsupportedOperationException("Lazy loading is not implemented.");
}
Run Code Online (Sandbox Code Playgroud)
但我想知道如何在不使用 LazyDataModel 的情况下做到这一点。
谢谢!