4 Replies Latest reply on Aug 28, 2007 9:39 AM by pmuir

    s:link works, h:commandButton doesn't

    dkane

      Hello.

      <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">
      ......
      
      <h:form id="termForm">
      
       <h:commandButton value="Dummy1" action="#{terminalAdm.dummy}"/>
       <s:link value="DummyLink1" action="#{terminalAdm.dummy}"/>
      </h:form>



      @Stateful
      @Name("terminalAdm")
      @Scope(ScopeType.SESSION)
      @SuppressWarnings("unchecked")
      public class TerminalAdmAction implements TerminalAdm
      {
      .....
       public void dummy()
       {
       System.out.println("DUMMY !!! ");
       }
      }
      



      When clicking on s:link, I see "DUMMY !!!" in console.
      When clicking on h:commandButton, I don't see that - action is not being invoked.
      How is this possible ?

      Thanks !


        • 1. Re: s:link works, h:commandButton doesn't

          The method signature for JSF actions is public String actionMethod() { ... } I suspect the void return type is the issue with the h:commandButton.

          • 2. Re: s:link works, h:commandButton doesn't

            No - that's not the problem at all. Void return values are perfectly fine in Seam. Both s:link and h:commandButton should work fine here.

            • 3. Re: s:link works, h:commandButton doesn't
              dkane

              I've solved the problem myself, but still have questions.

              There was h:selectOneMenu right before h:commandButton in my page.
              h:selectOneMenu was mapped to the session-scoped Seam component, and dislayed the list of entities with s:convertEntity tag. But this field did not remember the selected value somehow. I.e each time I clicked s:link the selected value returned to first item in list.

              I removed this h:selectOneMenu, and magically h:commandButton started to work !

              After that, I digged tons of forum threads and found the thesis that s:convertEntities should work in conversation scope only. Found no word abot that in Seam manual, but adding long-running conversation @Begin(join="true") made h:selectOneMenu stateful (no more resets after form submission).

              Then, I restored the original view of xhtml page : h:selectOneMenu and h:commandButton next . Everything works well.

              Questions :

              1) Is it possible, that incorrect processing of preceding JSF controls causes incorrect processing of following controls in the same page? (probably not pure Seam but JFS question)

              2) Does s:convertEntities, indeed, require long-running conversation ? If so - why ?

              • 4. Re: s:link works, h:commandButton doesn't
                pmuir

                 

                "dkane" wrote:
                1) Is it possible, that incorrect processing of preceding JSF controls causes incorrect processing of following controls in the same page? (probably not pure Seam but JFS question)


                On form submission (which h:commandXXX does), yes, as all sorts of errors can occur (e.g. model update, validation, conversion. You need to output these messages via h:messages

                2) Does s:convertEntities, indeed, require long-running conversation ? If so - why ?


                http://wiki.jboss.org/wiki/Wiki.jsp?page=SeamProblemsFAQ

                and search back across the forums, this has been explained many times. I'm going to move this into the reference manual soon.