Saving bean passed via ui:include

UI Components for JSF
Post Reply
Vikky
Posts: 7
Joined: 11 Jan 2011, 14:07

28 Jan 2011, 13:14

Hello, I would like to be able to use different actions on different beans passed vie input. The code might explain better:

Code: Select all

<ui:insert name="include" id="form">
          <ui:include src="/protected/List.xhtml">
                  <ui:param name="bean" value="#{behController}" />
          </ui:include>
 </ui:insert>
in the included file:

Code: Select all

<ui:composition>
         <h:inputHidden id="vybKurz" value="#{bean.vybranyKurz}" converter="kurzConverter"/>
        <p:dataTable value="#{bean.items}" var="item"
                     paginator="true" rows="10" emptyMessage="#{bundle.noRecords}">
                 <p:column>
                <f:facet name="header">
                    <h:outputText value="#{bundle.beh_konec}"/>
                </f:facet>
                <h:outputText value="#{item.konec}">
                    <f:convertDateTime pattern="dd.MM.yyyy" />
                </h:outputText>
            </p:column>
            <p:column >
                <f:facet name="header">
                    <h:outputText value="&nbsp;"/>
                </f:facet>
                <p:commandLink  action="#{bean.prepareView}"
                                value="#{bundle.view}"
                                ajax="false"
                                >
                    <f:setPropertyActionListener value="#{item}"
                                                 target="#{bean.selected}" />
                </p:commandLink>
                <h:outputText value=" "/>
                <p:commandLink action="#{bean.destroy}" value="#{bundle.destroy}"
                               ajax="false">
                    <f:setPropertyActionListener value="#{item}"
                                                 target="#{bean.selected}" />
                </p:commandLink>
                <h:outputText value=" "/>
                <p:commandLink action="#{bean.prepareEdit}" value="#{bundle.edit}"
                               ajax="false">
                    <f:setPropertyActionListener value="#{item}"
                                                 target="#{bean.selected}" />
                </p:commandLink>
                <h:outputText value=" "/>
            </p:column>
        </p:dataTable>
    </ui:composition>
But when trying to invoke the action the bean is not there anymore - I`d like to ask how to get around this problem? I thought I could use <h:inputHidden id="bean" value="#{bean}"/>, to keep the bean in the view, however then I would need somehow to do a converter for managed bean. Any ideas, please?

mikke
Posts: 7
Joined: 15 Dec 2010, 10:32

28 Jan 2011, 15:43

Hi!

Have you tried composite? I have been using it and it works as it is supposed to.

Here is sample:

Code: Select all

     <composite:interface>
        <composite:attribute name="backingBean" required="true" />
    </composite:interface>
    
    <composite:implementation>      
            
            <p:dataTable 
                         var="item" 
                         value="#{cc.attrs.backingBean.items}">         
                                  
                <p:column>
                    <h:outputText value="#{item.value}"/>
                  
                </p:column>
            </p:dataTable>

    </composite:implementation>
Apache tomcat 7.0.6, Myfaces 2.0.2, Primefaces 2.2.RC

Vikky
Posts: 7
Joined: 11 Jan 2011, 14:07

28 Jan 2011, 15:57

Hi,
I`m unfamiliar with composite, however I`ll try that. However I`m not sure, it will solve my problem - using my way the data are passed to the datatable, co I am able to see what is in there.
It only fails when I try to invoke the action. I think the problem is, that the nacking bean object gets lost once it the response is rendered. So try to call the action the backingBean no longer exists. I would think it would be the same with the attribute...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 48 guests