开发者

JSF - Load different forms based on mimetype values in DataTable using AJAX call

For one of my projects, I need to load different forms based on mimetype values available in DataTable components. I have header, content - DataTable in the middle and data display in the footer. Click on DataTable entry should load data on footer based on mimetype values. For example mimetype - text will call text bean and load the content, mimetype - pdf will call pdf bean and pdf plug in and so on.

Right now, I am able to display only one mimetype contents in single jsf page. I need to achieve this in single jsf page. Could anybody sends some inputs ?

Here is the sample code I am using - for text

<h:form id="form1">
    <h:dataTable value="#{info.office.programmers}" var="programmer">
        <h:column>
            <f:facet name="header">Report Name</f:facet>
                <h:commandLink id="reportName"  value="#{programmer.reportName}">
                    <f:param name="RID" value="#{programmer.reportName}" />
                    <f:param name="mime" value="#{program开发者_运维百科mer.mimeType}" />
                    <f:ajax render=":form2"/>
                </h:commandLink>
        </h:column>
        <h:column>
            <f:facet name="header">Mime Type</f:facet>
            <h:commandLink id="mimeType"  value="#{programmer.mimeType}">
                <f:param name="RID" value="#{programmer.reportName}" />
                <f:param name="mime" value="#{programmer.mimeType}" />
                <f:ajax render=":form2"/>
            </h:commandLink>
        </h:column>
    </h:dataTable>
</h:form>

Clicking on dataTable with mimetype="text" link will call Text.xhtml and display text data.

<h:form id="form2">
    <ui:include src="Text.xhtml"/>
</h:form>

Click on DataTable with mimetype="pdf" will call this form2

<h:form id="form2">
    <object data="/<directory>/DisplayPdf.jsf" type="application/pdf" width="100%" height="100%">
</h:form>


Use the rendered attribute to conditionally render components in the view.

<h:form id="form2">
    <h:panelGroup rendered="#{param.mime == 'text'}">
        <ui:include src="Text.xhtml"/>
    </h:panelGroup>
    <h:panelGroup rendered="#{param.mime == 'pdf'}">
        <object data="/<directory>/DisplayPdf.jsf" type="application/pdf" width="100%" height="100%">
    </h:panelGroup>
</h:form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜