3 Replies Latest reply on May 21, 2007 10:54 AM by Brian Smith

    Component Binding don't work in Seam?

    Brian Smith Apprentice

      I am trying to bind a couple Trinidad InputText components (UIXInput) in a SFSB.

      I keep getting an error message that the Backing Bean (SFSB) resolved to null. Do component bindings just not work in Seam? I know they are discouraged (sited in the documentation somewhere), but I don't remember anything saying they just don't work.

      Essentially what I am trying to do is clear out a couple of values on my form after I submit.

      Use case is two input components add data to a dataTable on form submit. I would like to clear the inputs after the data is added to the table, so if someone has a way to do this without bindings, I am all ears. I was under the impression I had to call setSubmittedValue(null) on the Input components to achieve this.

      I am using Seam 1.2.1GA

        • 1. Re: Component Binding don't work in Seam?
          Dennis Newbie

          Hello.

          It's works fine for me, but the documentation is a little bit strange in that.
          You can inject a Component into your bean.

          package de.psi.support.gui;

          import java.util.List;

          import javax.ejb.Remove;
          import javax.faces.component.html.HtmlDataTable;
          import javax.persistence.EntityManager;
          import javax.persistence.PersistenceContext;

          import org.jboss.seam.annotations.Destroy;
          import org.jboss.seam.annotations.In;

          public abstract class Selection {

          @PersistenceContext
          protected EntityManager em;

          private Object selected;

          @In("#{uiComponent['form:table']}")
          protected HtmlDataTable table;

          public String getSearch() {
          return search;
          }

          public void setSearch(String search) {
          this.search = search;
          }

          protected List getResult() {
          List query = em.createQuery(getQuery()).getResultList();
          return query;
          }

          public Object getSelected() {
          return selected;
          }

          public void setSelected(Object selected) {
          this.selected = selected;
          }

          public void select() {
          setSelected(table.getRowData());
          }

          It's a snippet of some of my classes (it's used only for inheritance -> abstract, try not to wonder about that.).

          @In("#{uiComponent['form:table']}")
          protected HtmlDataTable table;

          That's your solution, keep in mind that the 'form:table' is the path (id!) to the component. The ":" splits the id's and not "." like it is mentioned in the seam documentation.

          Good luck!

          • 2. Re: Component Binding don't work in Seam?
            Brian Smith Apprentice

            Thanks goose,

            So I have to use injection, I can't use regular JSF style binding?

            <h:inputText binding="#{mySFSB.someUIInputComponent}"/>


            Can you tell me where you found this in the Seam Documentation?

            Using your method, do I still need to wire up the binding (like shown above) in the JSF page? It appears that I don't since you don't have any getters or setters.........or are you simply binding to #{table}?

            • 3. Re: Component Binding don't work in Seam?
              Brian Smith Apprentice

              Also, what does #{uiComponent} reference?