h:commandButton and h:commandLink don't delegate conversatio
svadu Jan 25, 2007 7:04 PMHi All,
I have the following problem. I have a conversation scoped bean:
@Name("regionAction") @Scope(ScopeType.CONVERSATION) public class RegionAction implements Serializable { ... @In(required=false) @Out(required=false) private Generalarticle selectedArticle; /** * Current Region bean */ @Out(required=false) @In(required=false) @DataModelSelection private RegionBean region; @DataModel private List<RegionBean> allRegions; @Factory("allRegions") @Begin(join=true) public void loadAllRegions() { m_logger.trace("Loading all regions"); this.allRegions = em.createQuery("from RegionBean as r") .getResultList(); } @Begin(join=true) public String selectRegion(RegionBean aRegion) { this.region = aRegion; m_logger.debug("Current region is set to " + region); return RESULT_SHOW_REGION; } public String submitEditGisArticle() { if ( null != this.region ) { if ( this.region.getGisArticle() == null) { this.selectedArticle = createGisArticle(region); } else if ( region.getGisArticle() != null ) { this.selectedArticle = this.region.getGisArticle(); } } else { FacesMessages.instance().add("Region is not selected!"); } m_logger.trace("submitEditGisArticle with #{selectedArticle} = #0", this.selectedArticle); return RESULT_EDIT_ARTICLE; } }
From my understanding conversation begins with the factory method (which also seems to be backed up by logs)
And I have the start page with the following:
<s:link id="editLnk" value="#{message['edit']}" action="#{regionAction.submitEditGisArticle}" styleClass="texttoolbar" />
In this case the result of regionAction.submitEditGisArticle leads me to the next page with the following:
<h:form id="editForm"> <h:inputText id="title" value="#{selectedArticle.title}" required="true"></h:inputText> <h:inputTextarea id="mainTextId" value="#{selectedArticle.text}" /> <s:button id="submitBtn" value="save" action="success"></s:button> </h:form> <h:messages />
Now, this works fine (I get both region and selectedArticle carried across the conversation). But as soon as I replace s:link on the first page with the h:commandButton (I tried h:commandLInk as well) like this:
<h:form id="edtRgnArt"> <h:commandButton value="#{message['edit']}" action="#{regionAction.submitEditGisArticle}" /> </h:form>
Then logs, debugging and h:messages show that region is null inside submitEditGisArticle
Can anybody help with an advise what the problem might be?
I use myfaces(tried 1.1.4 and 1.1.5)+facelets(tried 1.1.11 and 1.1.12)+ajax4jsf(tried 1.0.5 and 1.0.6)+seam(tried 1.1.0 and 1.1.0) in all cases with the same result - the region bean is null.
Although the bean is null I still see this bean in a conversation context via debugger.xhtml:
Conversation Context (2) allRegions em org.jboss.seam.core.conversation org.jboss.seam.core.facesMessages org.jboss.seam.core.persistenceContexts region regionAction
Any help is appreciated!