ADF配置 LOV
创建 Student和Class表(假设表已经建好,并且 对应的Entity Object和View Object都已配好).
第一、创建页面 index.jsp ,edit.jsp和findClass.jsp
1、 其中index页面中建立student View Object的table 用于查询,并且创建一个
<af:commandButton text="修改" action="SAU"/>
<af:panelLabelAndMessage> <af:panelHorizontal> <af:outputLabel value="classId"/> <af:inputText value="#{bindings.ClassId.inputValue}" partialTriggers="classId" required="#{bindings.ClassId.mandatory}" columns="#{bindings.ClassId.displayWidth}" binding="#{Student.classIdInput}"> <af:validator binding="#{bindings.ClassId.validator}"/> <f:convertNumber groupingUsed="false" pattern="#{bindings.ClassId.format}"/> </af:inputText> <af:commandLink id="classId" action="dialog:open" returnListener="#{Student.handleReturn}"> <af:objectImage source="/images/searchicon_enabled.gif"/> </af:commandLink> </af:panelHorizontal> </af:panelLabelAndMessage>
<af:commandButton text="选择" actionListener="#{ClassBean.returnObject}"/>
public class CLassBean { private CoreTable resultTable; private String classId; public CLassBean() { } public void returnObject(ActionEvent actionEvent) { JUCtrlValueBindingRef vb = (JUCtrlValueBindingRef)this.getResultTable().getSelectedRowData(); if(vb==null){ AdfFacesContext.getCurrentInstance().returnFromDialog(null,null); return; } classId=vb.getRow().getAttribute("ClassId").toString(); this.setClassId(classId); AdfFacesContext.getCurrentInstance().returnFromDialog(this,null); } public void setResultTable(CoreTable resultTable) { this.resultTable = resultTable; } public CoreTable getResultTable() { return resultTable; } public void setClassId(String classId) { this.classId = classId; } public String getClassId() { return classId; }}
public class StudentBean { private CoreInputText classIdInput; public StudentBean() { } public void handleReturn(ReturnEvent returnEvent) { CLassBean cb = (CLassBean)returnEvent.getReturnValue(); if(cb==null){ return; } String classId=cb.getClassId(); this.getClassIdInput().setSubmittedValue(null); this.getClassIdInput().setValue(classId); AdfFacesContext.getCurrentInstance().addPartialTarget(this.getClassIdInput()); } public void setClassIdInput(CoreInputText classIdInput) { this.classIdInput = classIdInput; } public CoreInputText getClassIdInput() { return classIdInput; }}