I am using the DataModel & DataModelSelection annotations to manage a datalist.
The add and delete are working fine but the edit has a problem. The new values
are not being submitted from the edit page into the Managers edit action.
Below is my code
|
| @Stateful
| @Scope(SESSION)
| @Name("sheetManager")
| public class SheetManagerBean implements Serializable, SheetManager {
|
| @DataModel
| private List<Sheet> sheetList;
|
| @DataModelSelection
| @In(required = false)
| @Out(required = false)
| private Sheet sheet;
|
| @In
| private User user;
|
| @PersistenceContext(type = EXTENDED)
| private EntityManager em;
|
| @Factory("sheetList")
| public void findSheets() {
| sheetList = (List<Sheet>) em.createQuery(
| "select sheet from Sheet sheet where
sheet.owner=#{user}")
| .getResultList();
| }
|
| public void delete()
| {
| em.remove(sheet);
| sheetList.remove(sheet);
| }
|
| public void select()
| {
| }
|
| @Remove
| @Destroy
| public void destroy() {
| }
|
| public void add()
| {
| sheet.setOwner(user);
| em.persist(sheet);
| sheetList.add(sheet);
| }
|
| public void edit()
| {
| System.out.println("Name:" + sheet.getName());
| System.out.println("Description:" + sheet.getDescription());
| em.merge(sheet);
| em.flush();
| }
|
| public void publish()
| {
| System.out.println("In the SheetManager.publish() method");
| }
|
| }
|
| <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:a="https://ajax4jsf.dev.java.net/ajax"
| template="template.xhtml">
|
| <!-- content -->
| <ui:define name="content">
| <div>
| <div class="errors">
| <h:messages globalOnly="true"/>
| </div>
| <f:view>
| <div class="content2-pagetitle">My Tables</div>
|
| <h:outputText value="No Tables to display"
rendered="#{sheetList.rowCount==0}"/>
|
| <h:form>
| <h:dataTable styleClass="table" var="sheet" value="#{sheetList}"
rendered="#{sheetList.rowCount>0}">
|
| <h:column>
| <f:facet name="header">
| <h:outputText value="Name"/>
| </f:facet>
| <s:label value="#{sheet.name}"/>
| </h:column>
| <h:column>
| <f:facet name="header">
| <h:outputText value="Description"/>
| </f:facet>
| <s:label value="#{sheet.description}"/>
| </h:column>
| <h:column>
| <f:facet name="header">
| <h:outputText value="Published"/>
| </f:facet>
| <s:label value="#{sheet.published}"/>
| </h:column>
| <h:column>
| <f:facet name="header">
| <h:outputText value="Actions"/>
| </f:facet>
| <h:commandButton image="img/delete.png" alt="Delete"
title="Delete" type="submit" value="Delete" onclick="javascript:return
confirm('Do you really want to delete this sheet?');"
action="#{sheetManager.delete}"/>
|
| <s:link view="/editSheet.xhtml">
| <img src="img/edit.png" border="0px"/>
| </s:link>
|
| <h:commandButton image="img/publish.png" alt="Publish"
title="Publish" type="submit" rendered="#{!sheet.published}" value="Publish"
action="#{sheetManager.publish}"/>
| </h:column>
|
| </h:dataTable>
|
| <br/>
|
| </h:form>
|
| <s:button id="upload" value="Upload" view="/fileUpload.xhtml"/>
|
| </f:view>
|
| <div style="clear:both"/>
|
| </div>
| </ui:define>
|
| </ui:composition>
|
EditSheet.xhtml
| <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:s="http://jboss.com/products/seam/taglib"
| template="template.xhtml">
|
| <!-- content -->
| <ui:define name="content">
|
| <div>
| <f:view>
|
| <div class="content2-pagetitle">Edit Sheet Details</div>
|
| <div class="entry errors">
| <h:messages globalOnly="true"/>
| </div>
|
| <h:form>
|
| <h:panelGrid columns="2">
|
| Name: <h:inputText id="name"
value="#{sheet.name}" required="true"/>
|
| Description: <h:inputText id="description"
value="#{sheet.description}" required="true"/>
|
| </h:panelGrid>
|
| <div class="buttonBox">
| <h:commandButton type="submit" value="Save"
action="#{sheetManager.edit}"/>
|
| <s:button id="cancel" value="Cancel"
view="/myTables.xhtml"/>
| </div>
|
| </h:form>
| </f:view>
|
| </div>
|
| </ui:define>
|
| </ui:composition>
|
The debug statements in the manager class's edit method show that the edited
values are not being submitted from the editSheet.xhtml page.
Any ideas as to why this is not working?
Thanks in advance
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4078934#4078934
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4078934
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user