单击后渲染组件

时间:2014-03-18 08:13:40

标签: jsf primefaces datatable

我想在点击提交按钮后呈现数据表。

<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>

这是支持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";

DataTable.isLoaded = true; DataTable.Filter = false;是访问的静态布尔值。当isLoaded变为true时,我想显示表并隐藏过滤器面板..如何做到这一点.. ??

<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 个答案:

答案 0 :(得分:0)

您的组件似乎有点过载了似乎不必要的属性,例如: partialSubmit,process,selection,scrollable等。 这不应该是实际问题,但限制错误的可能性有助于更接近解决方案。

有些观点:

  • 这三个元素是同一个形式吗?您在更新中使用:form:table form:filter ,这并不清楚您使用的是哪种表单。

  • 是getValues()在控制台中给你任何输出还是甚至没有调用?你也不需要返回一个String,一个void方法就可以完成这个工作

  • 尝试使用#{menuBean.getValues},小m

  • 尝试更新@form,而不是特定元素