我不明白PrimeFaces选择器(PFS)是如何工作的.
<h:outputText value="#{bean.text1}" styleClass="myClass" />
<p:commandButton update="@(.myClass)" />
Run Code Online (Sandbox Code Playgroud)
我可以用它.我认为这是一个很棒的工具,虽然它并不总是对我有用.的.myClass
是客户端jQuery选择.服务器端的JSF如何知道要更新的内容?
我可以理解正常的JSF ID选择器是如何工作的.
<h:outputText value="#{bean.text1}" id="textId" />
<p:commandButton update="textId" />
Run Code Online (Sandbox Code Playgroud)
的textId
组件树的引用部件的ID作为在XHTML文件中定义在服务器端.所以我可以理解JSF如何找到合适的组件.
但是如果使用的是primefaces选择器,则使用客户端jQuery选择器.JSF如何知道哪个组件必须更新?有时我的PFS有问题.它似乎并不总是对我有用.如果您使用PFS,是否应该记住哪些内容?
我正在使用PrimeFaces 3.0-M3,我有<p:dataTable>
两列.我希望第一列固定在20px的宽度.另一列可以使用留下的任何空间.
以下是我目前获得的截图:
第一个<p:column>
似乎忽略了style
应该限制宽度的设置.它的尺寸太大,不适合小的彩色方块,它是其中唯一的内容,然后另一列被推得太远.
这里有更多我的Facelet代码:
<p:dataTable
id="dataTableExpressions"
value="#{catconBean.userDefinedExpressionDataModel}"
var="currentRow"
emptyMessage="!! EMPTY TABLE MESSAGE !!"
selection="#{catconBean.userDefinedExpressionToEdit}"
selectionMode="single">
<p:ajax
event="rowSelect"
listener="#{catconBean.onUserDefinedExpressionRowSelect}"
update=":toolbarForm:catconToolbar" />
<p:ajax
event="rowUnselect"
listener="#{catconBean.onUserDefinedExpressionRowUnselect}"
update=":toolbarForm:catconToolbar" />
<p:column id="paletteColor" style="width:20px;">
<h:panelGroup
layout="block"
rendered="#{not empty currentRow.paletteColor}"
style="width:16px;height:16px;border:thin;border-style:solid;border-color:black;background-color:##{currentRow.paletteColor.RGB};" />
<h:panelGroup
layout="block"
rendered="#{empty currentRow.paletteColor}"
style="width:16px;height:16px;border:thin;border-style:dashed;border-color:red;background-color:white;text-align:center;">
<h:outputText value="?" style="color:red;font-weight:bold;" />
</h:panelGroup>
</p:column>
<p:column id="name">
<f:facet name="header">
<h:outputText value="#{bundle.catcon_label_CategoryName}" />
</f:facet>
<h:outputText
value="#{currentRow.name}"
style="#{not currentRow.definitionComplete ? 'color:red;' : ''}" />
</p:column>
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我如何修改我的Facelet代码,使第一列的固定宽度为20px?
我在JSF页面的标题中包含了JQuery1.5.在该页面中,已经编码了许多Primefaces组件.在我Jquery.js
将页面标题包含在页面的标题之后,一些主要组件就像<p:commandButton>
失去了它们的皮肤一样,<p:fileUpload>
看起来像普通的JSP <input type="file">
并完全失去了它的AJAX功能.
有没有办法安全地使用JQuery和primefaces(没有冲突)?
据我知道@this是表示当前组件触发事件,比如:
<p:commandButton process="@this" ... />
Run Code Online (Sandbox Code Playgroud)
在JSF 2 Ajax中,@ this也可以表示封装组件,如:
<h:inputText ...>
<f:ajax execute="@this" ... />
</h:inputText>
Run Code Online (Sandbox Code Playgroud)
我有一个案例,其中使用p:datatable,包括或排除@this可能会对Ajax部分提交产生不同的影响
这里的例子,在这种情况下,该进程正在使用@this,这正常工作,当过程发生,其中第一,然后依次setPropertyActionListener和最后的动作被执行:
<p:column>
<p:commandLink
value="#{anggaranDetail.map['code']}"
process="@this infoAnggaranForm:Anggaran"
update="detailDialogForm:Anggaran detailDialogForm:SubAnggaran"
oncomplete="infoAnggaranDialog.hide()"
image="ui-icon ui-icon-search"
action="#{tInputBean.updateAnggaranSubAnggaran}">
<f:setPropertyActionListener value="#{anggaranDetail}"
target="#{infoAnggaranBean.selectedAnggaranDetail}" />
</p:commandLink>
</p:column>
Run Code Online (Sandbox Code Playgroud)
但是当我从这个例子中省略@this时,setPropertyActionListener和动作永远不会执行,好像它们不存在一样.
我想知道为什么 ?也许@this除了当前组件之外还有其他一些含义,也许是本例中的当前记录?
我使用tomcat 7,这些是我的依赖:
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud) 我创建了表单,我希望在新表创建时在表上显示以前的现有项目.我希望在填写表格时显示匹配的项目.但是当我尝试在没有完成表单的情况下过滤列表时,会出现验证消息,并且表格不会更新.
不知道是否可能,但我想做的事情是这样的:
<h:form id="form">
<h:outputText value="Name: "/>
<p:inputText value="#{itemsBean.name}" id="name" required="true"/>
<br/>
<h:outputText value="Description: "/>
<p:inputText value="#{itemsBean.description}" id="description" required="true"/>
<p:commandButton value="Save" update="form" actionListener="#{itemsBean.save}"/> //validate and save
<p:commandButton value="Filter" update="form" actionListener="#{itemsBean.updateItemsList}"/> //don't validate, and update the table.
<p:dataTable id="list" value="#{itemsBean.itemsList}" var="item">
<p:column>
<h:outputText value="#{item.name}"/>
</p:column>
<p:column>
<h:outputText value="#{item.description}"/>
</p:column>
</p:dataTable>
</h:form>
Run Code Online (Sandbox Code Playgroud)
我是JSF的新手.
一旦编辑了一个单元格,我就很难重新渲染PrimeFaces Datatable.更改一个单元格中的值可能会更改其他单元格中的条目,因此需要刷新整个表格.
这是JSF页面:
<h:form id="testForm">
<p:outputPanel id="testContainer">
<p:dataTable id="testTable" value="#{tableBean.data}" var="entry" editable="true" editMode="cell">
<p:ajax event="cellEdit" listener="#{tableBean.onCellEdit}" update=":testForm:testContainer" />
<p:column headerText="Col1">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{entry.col1}" /></f:facet>
<f:facet name="input"><p:inputText value="#{entry.col1}" /></f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Col2">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{entry.col2}" /></f:facet>
<f:facet name="input"><p:inputText value="#{entry.col2}" /></f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
<p:commandButton id="refreshButton" value="Redisplay" update="testContainer" />
</p:outputPanel>
</h:form>
Run Code Online (Sandbox Code Playgroud)
这是支持bean:
@ManagedBean(name = "tableBean", eager = false)
@ViewScoped
public class TableBean {
public TableBean() {
RowData entry = new RowData("a1", "b1");
entries.add(entry);
entry = new RowData("a2", "b2");
entries.add(entry); …
Run Code Online (Sandbox Code Playgroud) 我试图执行一个JSF2 bean方法,并在完成单击PrimeFaces的方法后显示一个对话框<p:commandButton>
.
<p:commandButton id="viewButton" value="View"
actionlistener="#{userBean.setResultsForSelectedRow}" ajax="false"
update=":selectedRowValues"
oncomplete="PF('selectedRowValuesDlg').show()">
</p:commandButton>
Run Code Online (Sandbox Code Playgroud)
<p:dialog id="selectedRowValues" widgetVar="selectedRowValuesDlg" dynamic="true">
<h:outputText value="#{userBean.selectedGroupName}" />
</p:dialog>
Run Code Online (Sandbox Code Playgroud)
当我单击命令按钮时,bean动作侦听器方法setResultsForSelectedRow
正确执行,但在方法完成时它不显示对话框.如果我删除actionlistener
,它会显示对话框.我不知道出了什么问题.
事件的执行顺序是什么?是否有可能执行actionlistener
和oncomplete
同步?
我在JBoss 7.1.1上使用PrimeFaces 3.2.
我试图在MySQL数据库中显示存储在BLOB中的图像<ui:repeat>
.图像存储在a中byte[]
,然后转换StreamedContent
为如下:
InputStream stream = new ByteArrayInputStream(ingredient.getImage());
ingredient.setJsfImage(new DefaultStreamedContent(stream, "image/jpg"));
Run Code Online (Sandbox Code Playgroud)
然后我试图在Facelet中显示它如下:
<ui:repeat var="ingredient" value="#{formBean.ingredientResultSet}">
<p:panel id="resultsPanel" header="#{ingredient.location.shopName}">
<p:graphicImage value="#{ingredient.jsfImage}" alt="No picture set" />
...
Run Code Online (Sandbox Code Playgroud)
但是,在加载页面时,我在JBoss中收到以下错误:
SEVERE [org.primefaces.application.PrimeResourceHandler](http - 127.0.0.1-8080-12)流式动态资源出错.
这是怎么造成的,我该如何解决?
我正在使用<p:dataTable>
PrimeFaces 3.3.1和分页.分页按钮显示在表格页眉和页脚中.我想隐藏表头中的分页按钮并将其保留在表格页脚中.我怎样才能做到这一点?
在许多地方,人们可以找到使用PF
Primefaces 的函数.例如在这个答案中
从我到目前为止所看到的,它似乎是一种神奇的"让它工作得更好"的功能.但我不相信这种东西:
这个功能有什么作用?
我在哪里可以找到有关它的文档?
primefaces ×10
jsf ×8
jsf-2 ×7
datatable ×2
action ×1
css ×1
graphicimage ×1
jquery-1.5 ×1
uirepeat ×1
validation ×1