我看到BalusC提供的这个例子:
<h:outputText value="#{bean.calendar.time}">
<f:convertDateTime type="both" dateStyle="long" />
</h:outputText>
Run Code Online (Sandbox Code Playgroud)
怎么用< h:commandLink>?
我试过了:
<h:commandLink value="#{question.creationDate.time}"
action="#{managerBean.searchQuestion()}">
<f:convertDateTime type="both" dateStyle="short" />
<f:setPropertyActionListener target="#{managerBean.questionID}"
value="#{question.ID}" />
</h:commandLink>
Run Code Online (Sandbox Code Playgroud) 环境:Tomcat 6,jsf 2.0,prime faces 2.2.1,chrome explorer
我想单击左侧展开树中的"ViewDetail"链接,并显示产品的详细信息.但是下面的代码不起作用.然后我将属性ajax ="false"添加到链接,似乎工作.但位于页面左侧的"p:treeTable"也会刷新并折叠.那么我该怎么办呢:单击左侧展开的树节点上的链接,在页面的右侧显示信息,并保持左展开的树节点仍然展开.
<h:form id="BizTypeTreeTableForm" >
<p:layout fullPage="true">
<p:layoutUnit id="left" position="left" scrollable="true" width="350" resizable="true" closable="false" collapsible="true" minWidth="250" >
<p:treeTable id="BizTypeTreeTable" value="# {treeTableController.root}" var="treeTable">
<p:column>
<f:facet name="header">ProductName</f:facet>
<h:outputText value="#{treeTable.TYPENAME.value }" />
</p:column>
<p:column style="width:5%">
<f:facet name="header">Action</f:facet>
<p:commandLink value="ViewDetail" update="content" action="#{treeTableController.showDetail}">
</p:commandLink>
</p:column>
</p:treeTable>
</p:layoutUnit>
<p:layoutUnit id="center" rendered="true" position="center" style="text-align:left;" scrollable="true" >
<h:outputText value="Please click the left tree node" rendered="# {allTabManager.productObject.TypeNo.value eq null}"/>
<div id="content" class="ui-widget">
<div class="post">
<ui:insert name="content_tab" >...</ui:insert>
</div>
</div>
</p:layoutUnit>
</p:layout>
</h:form>
Run Code Online (Sandbox Code Playgroud) 我试图通过commandlink在ajax请求后显示表单中的字段.但是,当我单击链接时,我收到malformedXML错误.xhtml文件如下所示:
<h:form>
.
.
<tr>
<td>Product Image*:</td>
<td>
<h:graphicImage url="#{addItem.prodFileName}" width="100" height="100"/>
<br /><h:commandLink value="change image" >
<f:ajax event="click" render="uploadimage" execute="@this" listener="#{addItem.ChangeImage}"/>
</h:commandLink>
</td>
</tr>
<tr >
<td>
<t:inputFileUpload rendered ="#{addItem.editImgChange}" label="editImage" id="uploadimage" value="#{addItem.uploadedFile}" />
<h:messages for="prodimage"/>
</td>
</tr>
.
.
</h:form>
Run Code Online (Sandbox Code Playgroud)
AddItem bean是RequestScoped,它有以下代码行:
@ManagedBean
public class AddItem extends AbstractBean {
//..
boolean editImgChange=false;
//...
public void ChangeImage(){
this.editImgChange=true;
}
}
Run Code Online (Sandbox Code Playgroud)
Inshort,我想只在用户点击更改图像链接后显示t:inputFileUpload字段.我在AddItem bean中保留了一个标志editImgChange,其初始值为false,一旦用户单击更改图像链接,该标志就会更改为true.该程序转到ChangeImage()方法,但之后我得到错误
"malformedXML:更新期间:找不到j_idt30:uploadimage"
.
我也会对一个完全不同的解决方案感到高兴,为了达到同样的效果,我的设计很糟糕.
以下代码是关于一个表,我可以在其中添加(commandButton)或删除(commandLink)行.这两个按钮都在工作并调用相应的bean方法.但是,对于每次单击添加按钮将更新表立即添加一行,对于删除按钮,我必须单击它两次以删除行.即使第一次没有删除该行,也会调用bean方法.我该怎么办?谢谢!
<h:form id="form">
<table>
<tr>
<td>
<h:panelGrid columns="2" width="100%">
<p:dataTable id="univertitiesTable" value="#{universityBean.universityList}" var="university"
editable="true" editMode="cell" style="align:center;" >
<p:column headerText="Name" style="width:80px" >
<p:inputText value="#{university.name}" style="width:25px;" id="nameField" label="name" />
</p:column>
<p:column headerText="" style="width:20px; ">
<p:commandLink actionListener="#{universityBean.deleteUniversity}" update="univertitiesTable" id="removeButton" ajax="true">
<h:graphicImage value="/resources/icones/delete.gif" />
<f:setPropertyActionListener value="#{university}"
target="#{universityBean.university}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:commandButton value="+" update="univertitiesTable" id="addButton" ajax="true"
actionListener="#{universityBean.addUniversity}"
styleClass="ui-priority-primary" />
</h:panelGrid>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<h:commandButton id="save" value="Save"
action="#{universityBean.save}" binding="#{save}" />
</td>
</tr>
</table>
</h:form>
Run Code Online (Sandbox Code Playgroud) I tried this but my commandlink disappeared. When i tried to find with firebug, it was there but with size 0 x 0 px.
.myNewButton {
width: 50px !important;
height: 50px !important;
background-image: url('/resources/img/e_menu_icons/x.png') !important ;
}
.myNewButton:hover {
width: 50px !important;
height: 50px !important;
background-image: url('/resources/img/e_menu_icons/e.png') !important ;
}
<p:commandLink styleClass="myNewButton" value=""
oncomplete="myDialog.show(); return false;"
action="#{myBean.actionMyAction()}">
</p:commandLink>
Run Code Online (Sandbox Code Playgroud) 我有一个命令链接如下.
<h:commandLink value="Home" action="homePage">
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)
这工作正常,但我需要一个图像而不是文本值.图像必须充当命令链接.
我怎样才能做到这一点?
我有一个分页的数据表,我想用数据表外的命令链接更改当前页面,我怎么能得到它?
<p:commandLink title="changePage" action="#{myBean.changeMethod}"
update="myDataTable" />
<p:dataTable id="myDataTable" var="myItem" paginator="true" rows="1"
value="#{myBean.ListOfItem}" binding="#{myBean.DataTable}">
...
...
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)
问候!
在我的JSF文件中,我在开始时就在下面.
<h:form><h:commandLink value="Create New Staff Account" action="adminCreateStaffMember"/></h:form>.
通过使用这个,当我创建时,Create New Staff Account我被重新定向到我有表格的页面来创建新帐户.
但是,当我使用相同的内部时dataTable,不采取行动.我还在同一页上:(
<h:dataTable var="c" value="#{newStaffMemberServiceBean.newStaffMemberDataBeanList}"
styleClass="order-table"
headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row"
border="1" id="staffListDataTable" width="100%">
<h:column>
<f:facet name="header">
Staff Member Name
</f:facet>
<h:form><h:commandLink value="Create New Staff Account" action="adminCreateStaffMember"/></h:form>
</h:column>
</h:dataTable>
Run Code Online (Sandbox Code Playgroud)
实际上我想要打印的是我将使用的相应工作人员的详细信息f:setPropertyActionListener.但由于上述情况不起作用,我不会继续.
请建议我哪里出错了.
我newStaffMemberServiceBean在RequestScoped
@ManagedBean(name = "newStaffMemberServiceBean")
@RequestScoped
public class NewStaffMemberServiceBean {
// some code
}
Run Code Online (Sandbox Code Playgroud)
HTML Generated如下
在外面 dataTable
<div align="right">
<form id="j_idt35" name="j_idt35" method="post" action="/adminManageStaffMember" enctype="application/x-www-form-urlencoded">
<input …Run Code Online (Sandbox Code Playgroud) 我试图在点击PrimeFace CommandLink时打开PrimeFace ConfirmDialog.但是当点击链接时,对话框会暂时打开,但会立即消失,我猜这个页面正在提交.这是代码:
<p:commandLink value="Delete" onclick="confirmation.show()" />
<p:confirmDialog message="Are you sure, you want to delete ?" header="Initiating deleting process" widgetVar="confirmation">
<p:commandButton value="Yes Sure" onclick="confirmation.hide()" actionListener="#{adminCtrl.deleteUserById}" update="userData" >
<f:attribute name="delete" value="#{user.userId}" />
</p:commandButton>
<p:commandButton value="Not Yet" onclick="confirmation.hide()" type="button" />
</p:confirmDialog>
Run Code Online (Sandbox Code Playgroud)
如何通过这种方式使对话框保持打开状态?
在PrimeFace ShowCase中,该示例处理CommandButton并且该工作正常,但我的要求是使用CommandLink.
可能吗?任何指针都对我很有帮助.
p:commandLink操作不会触发我的视图bean.我尝试过很多东西,但是我没有实现:((应该有一个简单的问题.如果你能帮助我,我将不胜感激.
<p:dataTable var="message" value="#{messagesView.dataModel}"
id="messageDt" emptyMessage="#{msg['kayitBulunamadi']}"
lazy = "true" paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,15,30" currentPageReportTemplate="{currentPage} / {totalPages}">
<p:column styleClass="min-image">
<f:facet name="header">
<h:outputText value="Durum" />
</f:facet>
<p:commandLink ajax="true" process="@this"
action="#{messagesView.selectedMessages(message)}"
oncomplete="PF('msjDialog').show();">
<!--<p:graphicImage value="#{message.mesajDurumu=='NEW'?'/images/DealerNewMessages.png':'/images/DealerReadMessage.png'}" style="width: 60px; height: 60px;" />-->
<p:graphicImage rendered="#{message.mesajDurumu=='REP'}"
value="/images/email-send.png" style="width: 30px; height: 30px;" />
<p:graphicImage rendered="#{message.mesajDurumu=='NEW'}"
value="/images/DealerNewMessages.png"
style="width: 30px; height: 30px;" />
<p:graphicImage
rendered="#{message.mesajDurumu!='REP' and message.mesajDurumu!='NEW'}"
value="/images/DealerReadMessage.png"
style="width: 30px; height: 30px;" />
</p:commandLink>
</p:column>
Run Code Online (Sandbox Code Playgroud)
Bean代码:
public void selectedMessages(DealerMessages msj) {
SELECTedMessage = msj;
oncekiMesajiAl(); …Run Code Online (Sandbox Code Playgroud) commandlink ×10
jsf ×7
primefaces ×6
jsf-2 ×4
java ×3
datatable ×2
ajax ×1
css ×1
datatables ×1
datetime ×1
dialog ×1
hover ×1
image ×1
layout ×1
pagination ×1