问题
I want to render the data table after clicking the button submit .
<p:commandButton value="Submit" action="#{MenuBean.getValues}"
type="submit" partialSubmit="true" process="statemenu,dist,@this"
style='font-family: font-family : Baskerville, "Baskerville Old Face",
"Hoefler Text", Garamond, "Times New Roman", serif;
font-size: 14px; font-weight: normal'
update=":form:table,:form:filter"></p:commandButton>
<p:dataTable id="table" value="#{DataTable.dataTable}" var="table"
lazy="true" rowKey="#{table.sheet_no}" selectionMode="single"
selection="#{DataTable.selectedSheet}" scrollable="true"
scrollHeight="150" rendered="#{DataTable.loaded}"
style="widht:400px ; margin-left:200px;margin-right:25px">
</p:dataTable>
<h:panelGrid id="filter" columns="1" cellpadding="10" cellspacing="2"
rendered="#{DataTable.filter}"
style="position:absolute;bottom:15px;right:150px;border: 1px solid #1f497d;box-shadow: 10px 10px 25px #888888;
height:auto;width:600px;Text-align:center;">
<p:outputLabel value="Filter your search to get result."></p:outputLabel>
</h:panelGrid>
Here is the backing bean
public String getValues() {
DataTable.isLoaded = true;
DataTable.Filter = false;
System.out.println("getting the values");
System.out.println(DataTable.isLoaded);
System.out.println(DataTable.Filter);
System.out.println(state);
System.out.println(district);
return "hello";
The DataTable.isLoaded = true; DataTable.Filter = false; are static boolean value which are accessed . When isLoaded becomes true i want to show the table and hide the filter panel .. how to do this..??
<p:dataTable id="disptable" value="#{DataTable.dataTable}"
var="table" lazy="true" rowKey="#{table.sheet_no}"
selectionMode="single" selection="#{DataTable.selectedSheet}"
scrollable="true" scrollHeight="150" rendered="#{DataTable.loaded}"
style="widht:auto ; margin-left:300px;margin-right:30px"
widgetVar="tabl">
<p:column headerText="Sheet Number" style="width:25%">
<h:outputLabel value="#{table.sheet_no}"></h:outputLabel>
</p:column>
<p:column headerText="State" style="width:25%">
<h:outputLabel value="#{table.state_cd}"></h:outputLabel>
</p:column>
<p:column headerText="District" style="width:25%">
<h:outputLabel value="#{table.district_cd}"></h:outputLabel>
</p:column>
<p:column headerText="Details" style="width:25%">
<h:commandLink title="Complete Details" value="Complete Details"></h:commandLink>
</p:column>
<f:facet name="footer">
<p:commandButton id="selectButton" icon="images\show.png"
update=":form:disp" oncomplete="PF('Dialog').show()"
process="@this,table" style="height:25px;"
action="#{tabs.addTabs}" ajax="true" />
<!-- Count of Items Selected : -->
</f:facet>
</p:dataTable>
回答1:
Your components seem to be a bit overloaded with attributes which don't seem necessary, e.g. partialSubmit, process, selection, scrollable etc. This shouldn't be the actual problem, but limiting possibilities for errors can help getting closer to the solution.
Some points:
are these three elements within the same form? You are using :form:table and form:filter in your update, this doesn't make clear what forms you are using.
is getValues() giving you any output in the console or is it not even called? You also don't need to return a String, a void method would do the job
try using #{menuBean.getValues}, with a small m
try updating @form, not specific elements
来源:https://stackoverflow.com/questions/22473678/render-the-components-after-the-click