1。rich:contextMenu 鼠标右键菜单
<rich:dataGrid id="dataTableId" styleClass="dataClass" columnClasses="timeTableCol1" value="#{staffCourseTable.weeklyTimeTable.dailyTimeTables[dayOfWeek].sections}" var="section" width="100%"> <t:div/> <rich:contextMenu id="contextMenu" attached="true" submitMode="ajax" attachTo="dataTableId" rendered="#{(section.type == 'MORNING_READING' ) or staffCourseTable.sectionEntries[section].schoolClass!=null or targetSubstitutionMap[section.id]==null or targetSwitchMap[section.id]==null}"> <rich:menuItem ajaxSingle="true" id="substitutionStaff" rendered="#{substitutionMap[section.id]==null and switchMap[section.id]==null}" action="substitutionStaff" reRender="#{flowRenderFragments}" value="#{msg['tcms']['subsititution']}"/> <rich:menuSeparator /> ----右键菜单分割线 <rich:menuItem/> </rich:contextMenu> </rich:dataGrid>
形成的效果即为在dataGrid中每格点击右键弹出contextMenu中内容, 在rich:contextMenu 中 attachTo 中值为dataGrid的id,即为应用组件。每个rich:menuItem即为菜单内容,在rich:menuItem中还可用a4j:actionparam传递参数。
2。rich:componentControl 控制
先拿一个例子。
<rich:modalPanel id="dayCoursePanel" width="300" height="600" showWhenRendered="#{showForm}"> <f:facet name="header"> <h:outputText value="#{msg['tcms']['dayCourseDetail']}" /> </f:facet> <f:facet name="controls"> <h:panelGroup> <h:graphicImage value="/images/close.png" id="hidelinkDayCourse" style="cursor: pointer;" mce_style="cursor: pointer;" /> <rich:componentControl for="dayCoursePanel" attachTo="hidelinkDayCourse" operation="hide" event="onclick" /> </h:panelGroup> </f:facet> </rich:modalPanel>
这是一个关闭modalPanel的例子,点击图片即可关闭整个modelPanel,rich:componentControl 中attachTo属性关联到图片的id,operation即为要进行的操作;for为此动作应用的组件; event为时间的触发。
3。rich:pickList 从list中筛选
<rich:pickList id="staffPickList" value="#{staffCourseExporterAction.staffList}" converter="#{staffConverter}" listsHeight="300" sourceListWidth="100" targetListWidth="100" copyAllControlLabel="#{msg['tcms']['selectAll']}" removeAllControlLabel="#{msg['tcms']['clearAll']}" copyControlLabel="#{msg['tcms']['choose']}" removeControlLabel="#{msg['tcms']['clear']}"> <c:forEach items="#{staffs}" var="staff"> <f:selectItem itemLabel="#{staff.nameCn}" itemValue="#{staff}" /> </c:forEach> <a4j:support event="onlistchanged" id="staffListChange" reRender="resultStaff" /> </rich:pickList>
在rich:pickList中应该注意converter应该重写。
@Component("staffConverter")
public class StaffConverter extends GenericJpaEntityConverter<Staff> {
}
copyAllControlLabel="#{msg['tcms']['selectAll']}"
removeAllControlLabel="#{msg['tcms']['clearAll']}"
copyControlLabel="#{msg['tcms']['choose']}"
removeControlLabel="#{msg['tcms']['clear']}"
都是显示标签。
在其中还应注意到a4j:support 有另一种event="onlistchanged"当list发生变化时便会触动事件action。