I have a stateful session bean called SiteEditor (Conversation scoped) with a 
create method. I wish to from a page backed by this bean, to open up another 
page with a SiteEditor bean as its backing bean (new data). 

When trying to do this I can open the first siteEditor page, but when I use the 
link to open up the new siteEditor page (it refreshes but shows the old data). 

The two relevant functions in the siteEditor bean are :


  | @Create 
  | @Begin(join=true)
  |     public void createSiteEditor(){
  |             
  |             log.info("Creating");
  |             
  |             if (utilityID.getId() == 0){
  |                     site = new Site();
  |                     isNew = true;
  |             } else {
  |                     site = (Site) em.find(Site.class, utilityID.getId());
  |                     if (site==null){
  |                             // TODO throw error, no site found for the id. 
  |                     } else {
  |                             siteChildren = site.getChildren();
  |                             isNew = false;
  |                     }
  |             }
  |     }
  | 

and 


  | @End
  |     public String editContract(){
  |             if (utilityID==null) utilityID = new UtilityId();
  |             utilityID.setId(selectedChild.getId());
  |             
  |             if (selectedChild instanceof Site)
  |                     return "showsite";
  |             else if (selectedChild instanceof Plot)
  |                     return "editplot";
  |             else if (selectedChild instanceof Region)
  |                     return "editregion";
  |             else if (selectedChild instanceof Block)
  |                     return "editblock";
  |             else if (selectedChild instanceof Phase)
  |                     return "editphase";
  |             else 
  |                     return "error";
  |     }
  | 

I also put a log messge in the @Destroyed method and I see this occur in the 
expected pattern. 
The one issue that causes my problem is that when I press on the button the 
first time the create function is not called, its as if the page is reusing the 
siteEditor left over from the previous conversation (even though I called the 
@End method). 

One extra piece of information is that if I then repress on the same 
commandButton a second time a new siteEditor is created. 

The xhtml code is as follows:


  | <ui:define name="body">
  |             <h1>Site Editor</h1>
  |             <h:form>
  |                 <table>
  |                         <tr>
  |                             <td><h:outputText value="Name" /></td>
  |                             <td><h:inputText 
value="#{siteEditor.site.name}" /></td>
  |                             <td></td>
  |                             <td rowspan="8" vAlign="top">
  |                             
  |                                 <c:if test="#{siteEditor.new}" >
  |                                    <table> 
  |                                            <tr><td>
  |                                                     <h:commandButton 
action="#{siteEditor.create}" value="Create" rendered="#{siteEditor.new}"
  |                                                  class="formButton" 
style="width: 166px;"/>
  |                                    </td></tr>
  |                                    <tr><td>
  |                                                     <h:commandButton 
action="#{siteEditor.done}" value="Cancel"  
  |                                                  class="formButton" 
style="width: 166px;" immediate="true"/>
  |                                    </td></tr>
  |                                </table>
  |                                 </c:if>
  |                                 <c:if test="#{!siteEditor.new}">
  |                                    <table> 
  |                                            <tr><td> 
  |                                             <h:commandButton 
action="#{siteEditor.update}" value="Update"
  |                                                      class="formButton" 
style="width: 166px;"/>
  |                                    </td></tr>
  |                                    <tr><td>
  |                                     <h:commandButton 
action="#{siteEditor.delete}" value="Delete" 
  |                                                      class="formButton" 
style="width: 166px;" immediate="true"/>
  |                                    </td></tr>
  |                                    <tr><td>
  |                                     <h:commandButton 
action="#{siteEditor.done}" value="Finish"  
  |                                                      class="formButton" 
style="width: 166px;" immediate="true"/>
  |                                    </td></tr>
  |                               </table>
  |                                 </c:if>
  |                             </td>  
  |                         </tr>
  |                         <tr>             
  |                                 <td><h:outputText value="Parent" /></td>
  |                             <td>
  |                                 <h:selectOneMenu 
value="#{siteEditor.site.parent}" converter="ContractConverter" >
  |                                             <f:selectItems 
value="#{selectItems.contractList}" />
  |                                     </h:selectOneMenu> 
  |                             </td>
  |                                 </tr>
  |                         <tr>             
  |                                 <td><h:outputText value="ID" /></td>
  |                             <td><h:inputText 
value="#{siteEditor.site.accountsID}" /></td>
  |                                 </tr>
  |                                 <tr>             
  |                                 <td><h:outputText value="Area" /></td>
  |                             <td><h:inputText 
value="#{siteEditor.site.area}" /></td>
  |                                 </tr>
  |                                 <tr>             
  |                                 <td><h:outputText value="Address" /></td>
  |                             <td><h:inputText 
value="#{siteEditor.site.address.housename}" /></td>
  |                                 </tr>
  |                                 <tr>             
  |                                 <td></td>
  |                             <td><h:inputText 
value="#{siteEditor.site.address.streetname}" /></td>
  |                                 </tr>
  |                                 <tr>             
  |                                 <td></td>
  |                             <td><h:inputText 
value="#{siteEditor.site.address.town}" /></td>
  |                                 </tr>
  |                                 <tr>             
  |                                 <td></td>
  |                             <td><h:inputText 
value="#{siteEditor.site.address.city}" /></td>
  |                                 </tr>
  |                                 <tr>             
  |                                 <td></td>
  |                             <td><h:inputText 
value="#{siteEditor.site.address.county}" /></td>
  |                                 </tr>
  |                                 <tr>             
  |                                 <td></td>
  |                             <td><h:inputText 
value="#{siteEditor.site.address.postcode}" /></td>
  |                                 </tr>
  |                                 <tr>             
  |                                 <td><h:outputText value="Price" /></td>
  |                             <td><h:inputText 
value="#{siteEditor.site.price}" /></td>
  |                                 </tr>
  |                                 <tr>             
  |                                 <td><h:outputText value="Sub Contracts" 
/></td>
  |                             <td></td>
  |                                 </tr>
  |                                 <tr>             
  |                                 <td colspan="2">
  |                                     <h:dataTable value="#{siteChildren}" 
var="c" rendered="#{siteChildren.rowCount>0}">
  |                                             <h:column>
  |                                                                     
<f:facet name="header">ID</f:facet>
  |                                                     <h:outputText 
value="#{c.accountsID}" />
  |                                             </h:column>
  |                                             <h:column>
  |                                                                     
<f:facet name="header">Name</f:facet>
  |                                                     <h:outputText 
value="#{c.name}" />
  |                                             </h:column>
  |                                             <h:column>
  |                                                                     
<f:facet name="header">Action</f:facet>
  |                                                     <h:commandButton 
action="#{siteEditor.editContract}" value="View" />
  |                                             </h:column>
  |                                     </h:dataTable>  
  |                                 </td>
  |                                 </tr>
  |                         </table>
  |                             <h:messages showDetail="true" />
  |                             
  |             </h:form>
  |             
  |                                                 
  |         </ui:define>
  | 

If anybody has any ideas I would be very greatful. 

Many thanks, 

James 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3915889#3915889

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3915889


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to