您好我正在使用Oracle ADF和jdeveloper11.1.2.4开发Web应用程序。实际上我有一个包含fllowing查询和表单的页面。搜索和一切都很好,但第一次加载页面时是空的。看起来不太好看。所以我的想法是这个表格应该最初是不可见的,只有在用户点击搜索(af:查询)中的搜索按钮后才能看到它。
请帮帮我。我怎么能做到这一点。
提前致谢。
以下是我的.jsf代码
<?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">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:document title="Search/Modfiy KPI" id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<af:pageTemplate viewId="/adminPageTemplate.jsf" id="pt1">
<f:facet name="Center">
<af:panelStretchLayout id="psl1">
<f:facet name="bottom"/>
<f:facet name="center">
<af:panelSplitter id="ps1" orientation="vertical" dimensionsFrom="children"
splitterPosition="191">
<f:facet name="first">
<af:panelGroupLayout layout="vertical" id="pgl1">
<af:query id="qryId1" headerText="Search KPI" disclosed="true"
value="#{bindings.KpiSearchCriteriaQuery.queryDescriptor}"
model="#{bindings.KpiSearchCriteriaQuery.queryModel}"
queryOperationListener="#{bindings.KpiSearchCriteriaQuery.processQueryOperation}"
fieldWidth="110"
queryListener="#{pageFlowScope.updateORDeleteBean.customSearch}"
partialTriggers="::pfl1"/>
</af:panelGroupLayout>
</f:facet>
<f:facet name="second">
<af:panelGroupLayout id="pgl5" layout="vertical" halign="center">
<af:panelGroupLayout id="pgl3" layout="horizontal" halign="center">
<af:panelGroupLayout layout="horizontal" id="pgl2">
<f:facet name="separator">
<af:spacer width="10" height="1" id="s1"/>
</f:facet>
<af:commandButton actionListener="#{bindings.First.execute}"
text="First" disabled="#{!bindings.First.enabled}"
partialSubmit="true" id="cb1"/>
<af:commandButton actionListener="#{bindings.Previous.execute}"
text="Previous"
disabled="#{!bindings.Previous.enabled}"
partialSubmit="true" id="cb2"/>
<af:commandButton actionListener="#{bindings.Next.execute}" text="Next"
disabled="#{!bindings.Next.enabled}"
partialSubmit="true" id="cb3"/>
<af:commandButton actionListener="#{bindings.Last.execute}" text="Last"
disabled="#{!bindings.Last.enabled}"
partialSubmit="true" id="cb4"/>
</af:panelGroupLayout>
<af:spacer width="10" height="10" id="s3"/>
<af:panelGroupLayout id="pgl4" layout="horizontal">
<af:commandButton text="Delete" id="cb5"
actionListener="#{updateORDeleteBean.delete}"/>
<af:spacer width="10" height="10" id="s2"/>
<af:commandButton text="Update" id="cb6"
actionListener="#{updateORDeleteBean.update}"/>
</af:panelGroupLayout>
</af:panelGroupLayout>
<af:panelFormLayout id="pfl1" visible="#{pageFlowScope.showForm}">
<af:inputText value="#{bindings.Id.inputValue}"
label="#{bindings.Id.hints.label}"
required="#{bindings.Id.hints.mandatory}"
columns="#{bindings.Id.hints.displayWidth}"
maximumLength="#{bindings.Id.hints.precision}"
shortDesc="#{bindings.Id.hints.tooltip}" id="it1"
readOnly="true">
<f:validator binding="#{bindings.Id.validator}"/>
<af:convertNumber groupingUsed="false" pattern="#{bindings.Id.format}"/>
</af:inputText>
<af:inputText value="#{bindings.KpiName.inputValue}"
label="#{bindings.KpiName.hints.label}"
required="#{bindings.KpiName.hints.mandatory}" columns="110"
maximumLength="#{bindings.KpiName.hints.precision}"
shortDesc="#{bindings.KpiName.hints.tooltip}" id="it2">
<f:validator binding="#{bindings.KpiName.validator}"/>
</af:inputText>
<af:inputText value="#{bindings.KpiSql.inputValue}"
label="#{bindings.KpiSql.hints.label}"
required="#{bindings.KpiSql.hints.mandatory}" columns="110"
maximumLength="#{bindings.KpiSql.hints.precision}"
shortDesc="#{bindings.KpiSql.hints.tooltip}" id="it3"
rows="3">
<f:validator binding="#{bindings.KpiSql.validator}"/>
</af:inputText>
<af:selectOneChoice value="#{bindings.Category.inputValue}"
label="#{bindings.Category.label}"
required="#{bindings.Category.hints.mandatory}"
shortDesc="#{bindings.Category.hints.tooltip}"
id="soc1">
<f:selectItems value="#{bindings.Category.items}" id="si1"/>
</af:selectOneChoice>
<af:selectOneChoice value="#{bindings.Module.inputValue}"
label="#{bindings.Module.label}"
required="#{bindings.Module.hints.mandatory}"
shortDesc="#{bindings.Module.hints.tooltip}" id="soc2">
<f:selectItems value="#{bindings.Module.items}" id="si2"/>
</af:selectOneChoice>
<af:selectOneChoice value="#{bindings.Submodule.inputValue}"
label="#{bindings.Submodule.label}"
required="#{bindings.Submodule.hints.mandatory}"
shortDesc="#{bindings.Submodule.hints.tooltip}"
id="soc3">
<f:selectItems value="#{bindings.Submodule.items}" id="si3"/>
</af:selectOneChoice>
<af:inputText value="#{bindings.Threshold.inputValue}"
label="#{bindings.Threshold.hints.label}"
required="#{bindings.Threshold.hints.mandatory}" columns="15"
maximumLength="#{bindings.Threshold.hints.precision}"
shortDesc="#{bindings.Threshold.hints.tooltip}" id="it4">
<f:validator binding="#{bindings.Threshold.validator}"/>
<af:convertNumber groupingUsed="false"
pattern="#{bindings.Threshold.format}"/>
</af:inputText>
<af:selectOneChoice value="#{bindings.Operator1.inputValue}"
label="#{bindings.Operator1.label}"
required="#{bindings.Operator1.hints.mandatory}"
shortDesc="#{bindings.Operator1.hints.tooltip}"
id="soc4">
<f:selectItems value="#{bindings.Operator1.items}" id="si4"/>
</af:selectOneChoice>
<af:inputText value="#{bindings.Helptext.inputValue}"
label="#{bindings.Helptext.hints.label}"
required="#{bindings.Helptext.hints.mandatory}" columns="110"
maximumLength="#{bindings.Helptext.hints.precision}"
shortDesc="#{bindings.Helptext.hints.tooltip}" id="it5">
<f:validator binding="#{bindings.Helptext.validator}"/>
</af:inputText>
<af:inputText value="#{bindings.PerfReason.inputValue}"
label="#{bindings.PerfReason.hints.label}"
required="#{bindings.PerfReason.hints.mandatory}"
columns="110"
maximumLength="#{bindings.PerfReason.hints.precision}"
shortDesc="#{bindings.PerfReason.hints.tooltip}" id="it6">
<f:validator binding="#{bindings.PerfReason.validator}"/>
</af:inputText>
<af:inputText value="#{bindings.XaxisDescription.inputValue}"
label="#{bindings.XaxisDescription.hints.label}"
required="#{bindings.XaxisDescription.hints.mandatory}"
columns="110"
maximumLength="#{bindings.XaxisDescription.hints.precision}"
shortDesc="#{bindings.XaxisDescription.hints.tooltip}"
id="it7">
<f:validator binding="#{bindings.XaxisDescription.validator}"/>
</af:inputText>
<af:inputText value="#{bindings.YaxisDesciption.inputValue}"
label="#{bindings.YaxisDesciption.hints.label}"
required="#{bindings.YaxisDesciption.hints.mandatory}"
columns="110"
maximumLength="#{bindings.YaxisDesciption.hints.precision}"
shortDesc="#{bindings.YaxisDesciption.hints.tooltip}"
id="it8">
<f:validator binding="#{bindings.YaxisDesciption.validator}"/>
</af:inputText>
<af:inputText value="#{bindings.Dschemaname.inputValue}"
label="#{bindings.Dschemaname.hints.label}"
required="#{bindings.Dschemaname.hints.mandatory}"
columns="50"
maximumLength="#{bindings.Dschemaname.hints.precision}"
shortDesc="#{bindings.Dschemaname.hints.tooltip}" id="it9">
<f:validator binding="#{bindings.Dschemaname.validator}"/>
</af:inputText>
<af:inputText value="#{bindings.Dtablename.inputValue}"
label="#{bindings.Dtablename.hints.label}"
required="#{bindings.Dtablename.hints.mandatory}"
maximumLength="#{bindings.Dtablename.hints.precision}"
shortDesc="#{bindings.Dtablename.hints.tooltip}" id="it10"
columns="50">
<f:validator binding="#{bindings.Dtablename.validator}"/>
</af:inputText>
<af:inputText value="#{bindings.Dfieldname.inputValue}"
label="#{bindings.Dfieldname.hints.label}"
required="#{bindings.Dfieldname.hints.mandatory}" columns="50"
maximumLength="#{bindings.Dfieldname.hints.precision}"
shortDesc="#{bindings.Dfieldname.hints.tooltip}" id="it11">
<f:validator binding="#{bindings.Dfieldname.validator}"/>
</af:inputText>
<af:inputText value="#{bindings.Toemail.inputValue}"
label="#{bindings.Toemail.hints.label}"
required="#{bindings.Toemail.hints.mandatory}" columns="50"
maximumLength="#{bindings.Toemail.hints.precision}"
shortDesc="#{bindings.Toemail.hints.tooltip}" id="it12">
<f:validator binding="#{bindings.Toemail.validator}"/>
</af:inputText>
<af:inputText value="#{bindings.CcEmail.inputValue}"
label="#{bindings.CcEmail.hints.label}"
required="#{bindings.CcEmail.hints.mandatory}" columns="50"
maximumLength="#{bindings.CcEmail.hints.precision}"
shortDesc="#{bindings.CcEmail.hints.tooltip}" id="it13">
<f:validator binding="#{bindings.CcEmail.validator}"/>
</af:inputText>
<af:selectOneChoice value="#{bindings.AutomoniterEnabled.inputValue}"
label="#{bindings.AutomoniterEnabled.label}"
required="#{bindings.AutomoniterEnabled.hints.mandatory}"
shortDesc="#{bindings.AutomoniterEnabled.hints.tooltip}"
id="soc5">
<f:selectItems value="#{bindings.AutomoniterEnabled.items}" id="si5"/>
</af:selectOneChoice>
<af:inputText value="#{bindings.AuditInfo.inputValue}"
label="#{bindings.AuditInfo.hints.label}"
required="#{bindings.AuditInfo.hints.mandatory}"
columns="#{bindings.AuditInfo.hints.displayWidth}"
maximumLength="#{bindings.AuditInfo.hints.precision}"
shortDesc="#{bindings.AuditInfo.hints.tooltip}" id="it14"
readOnly="true">
<f:validator binding="#{bindings.AuditInfo.validator}"/>
</af:inputText>
<f:facet name="footer"/>
</af:panelFormLayout>
</af:panelGroupLayout>
</f:facet>
</af:panelSplitter>
</f:facet>
<f:facet name="start"/>
<f:facet name="end"/>
<f:facet name="top"/>
</af:panelStretchLayout>
</f:facet>
</af:pageTemplate>
</af:form>
</af:document>
</f:view>
以下是我的Java类代码
public void customSearch(QueryEvent queryEvent) {
// Add event code here...
System.out.println("in custom srch");
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("showForm", true);
invokeEL("#{bindings.KpiSearchCriteriaQuery.processQuery}", new Class[] { QueryEvent.class },
new Object[] { queryEvent });
System.out.println("end custom srch");
}
答案 0 :(得分:2)
只有当用户按下“搜索”按钮时,才能在panelFormLayout上将“visible”属性设置为true:
<af:panelFormLayout visible="#{pageFlowScope.showForm}">
为此,您需要覆盖af:query:
的“queryListener”方法<af:query queryListener="#{yourBean.customSearch}"/>
在YourBean.java中,您将拥有:
public void customSearch(QueryEvent queryEvent) {
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("showForm", true);
//call your original queryListener- the one you changed in page:
invokeEL("#{bindings.DepartmentsViewCriteriaQuery.processQuery}", new Class[] { QueryEvent.class },
new Object[] { queryEvent });
}
更多细节,这里: http://www.awasthiashish.com/2013/12/overriding-default-query-listener-field.html