I'm actually trying to pass a view scoped bean to the next page. The first column in datatable(see DATATABLE.xhtml) is an <h:commandLink> with a parameter containing the id I need for making a query to DB. I've defined a Navigation Handler in faces-config.xml define the mechanism for forwarding the request to another xhtml page once the action #{metadataClassTable.edit} has done. The new page (EDIT.xhtml) use the view scoped bean #{metadataClass} that I try to populate into the "edit" method:
The things work only when using session as scope. With view scope the input textfields in the EDIT page are empty and I've some problem for displaying collection data of metadataClass in a datatable using dynamic="true" attribute (With dynamic="false" instead I can see List collection data).
Someone knows what is the correct way for resolving view scoped bean programmatically?
Snippet of 'edit' action: #{metadataClassTable.edit}
Code: Select all
FacesContext context = FacesContext.getCurrentInstance();
ELResolver resolver = context.getApplication().getELResolver();
MetadataClass wsClass = (MetadataClass) resolver.getValue(context.getELContext(), null, "metadataClass");
wsClass.setMetaClassName("Mock Name");
wsClass.setDescription( "Mock Description" );
List<MetaInfo> infoes = new ArrayList<MetaInfo>();
infoes.add(new MetaInfo());
wsClass.setSomeList(infoes);
Code: Select all
<p:dataTable var="mdClass" value="#{metadataClassTable.list}" rows="10" dynamic="true">
<p:column>
<f:facet name="header">
<h:outputText value="" />
</f:facet>
<h:commandLink value="Edit" id="editLink" action="#{metadataClassTable.edit}" >
<f:param name="classID" value="#{mdClass.idMetadataClass}"/>
</h:commandLink>
</p:column>
<p:column sortBy="#{mdClass.className}" filterBy="#{mdClass.className}">
<f:facet name="header">
<h:outputText value="#{bundle.gui_metaClass_name}" />
</f:facet>
<h:outputText value="#{mdClass.className}" />
</p:column>
<p:column filterBy="#{mdClass.description}">
<f:facet name="header">
<h:outputText value="#{bundle.gui_metaClass_description}" />
</f:facet>
<h:outputText value="#{mdClass.description}" />
</p:column>
</p:dataTable>
Code: Select all
<h:form prependId="false">
<p:panel id="panel" header="Metadata Class">
<p:messages id="msgs" showDetail="true"/>
<h:panelGrid columns="3">
<h:outputLabel for="metaName" value="#{bundle.gui_metaClass_name}: *" />
<h:inputText id="metaName" value="#{metadataClass.metaClassName}" required="true">
<f:validateLength minimum="2" />
<p:ajax event="blur" update="metaNameMsg, growl,msgs"/>
</h:inputText>
<p:message for="metaName" id="metaNameMsg" />
<h:outputLabel for="description" value="#{bundle.gui_metaClass_description}: " />
<h:inputText id="description" value="#{metadataClass.description}" size="50"/>
<p:message for="description" />
</h:panelGrid>
<p:commandButton id="delete" value="Delete" update="growl,msgs"
async="true" actionListener="#{metadataClass.delete}"
oncomplete="toggleDisabled()" onstart="toggleDisabled()"/>
<h:commandButton id="backButton" value="Back" action="back"/>
</p:panel>
</h:form>