Title: Message

Kris, are you using JSF-RI?

 

I have similar ‘id‘-problems when testing h:selectBooleanCheckbox inside x:datatable and using JSF-RI+MyFaces extensions.

Id of selectBooleanCheckbox is same on each table row.

 

I don’t get this problems using MyFaces environment – and that’s also how the examples are configured.

---Vli---

 


From: Kris Verhoye [mailto:[EMAIL PROTECTED]
Sent: 31. toukokuuta 2005 16:35
To: [email protected]
Subject: x:dataTable doesn't render an id per row?

 

Hi!

 

I know that there have been a lot of questions regarding the dataTable, but I still can't get mine to work.

 

I have a table which looks like this:

 

            <x:dataTable id="pubTable"
                         styleClass="publicationTable"
                         headerClass="publicationTable_SortHeader"
                         rowClasses="publicationTable_row1,publicationTable_row2"
                         var="publication"
                         value="#{publicationsBean.publicationModel}"
                         sortColumn="#{publicationsBean.sort}"
                         sortAscending="#{publicationsBean.ascending}"
                         preserveDataModel="true"
                         preserveSort="true">
              <h:column>
                <f:facet name="header">
                  <h:panelGroup></h:panelGroup>
                </f:facet>
                <h:graphicImage alt="#{pubmgr_messages['alt_validated']}"
                                url="" == 'true' ? pubmgr_messages['img_greenlight'] : pubmgr_messages['img_redlight']}">
                </h:graphicImage>
              </h:column>
              <h:column>
                <f:facet name="header">
                  <x:commandSortHeader columnName="code" arrow="true">
                    <h:outputText value="Code" />
                  </x:commandSortHeader>
                </f:facet>
                <x:commandLink action="" immediate="true" styleClass="publication_select">
                  <x:outputText value="#{publication.code}" />
                </x:commandLink>
              </h:column>
              <h:column>
                <f:facet name="header">
                  <x:commandSortHeader columnName="name" arrow="true">
                    <h:outputText value="Name" />
                  </x:commandSortHeader>
                </f:facet>
                <h:outputText value="#{publication.names['en']}" />
              </h:column>
            </x:dataTable>

 

The table is rendered to this:

 

<table id="pubForm:pubTable" class="publicationTable">
<thead>

 

<tr><th class="publicationTable_SortHeader"></th><th class="publicationTable_SortHeader"><a href="" false;" id="pubForm:pubTable:_id11">Code</a></th><th class="publicationTable_SortHeader"><a href="" false;" id="pubForm:pubTable:_id16">Name&#x2193;</a></th></tr></thead>
<tbody>
<tr class="publicationTable_row1"><td><img id="pubForm:pubTable:_id9" src="" alt="validate status"/></td><td><a href="" false;" id="pubForm:pubTable:_id13" class="publication_select">testcode1</a></td><td>testname1</td></tr>
<tr class="publicationTable_row2"><td><img id="pubForm:pubTable:_id9" src="" alt="validate status"/></td><td><a href="" false;" id="pubForm:pubTable:_id13" class="publication_select">testcode2</a></td><td>testname2</td></tr>
<tr class="publicationTable_row1"><td><img id="pubForm:pubTable:_id9" src="" alt="validate status"/></td><td><a href="" false;" id="pubForm:pubTable:_id13" class="publication_select">testcode3</a></td><td>testname3</td></tr>
<tr class="publicationTable_row2"><td><img id="pubForm:pubTable:_id9" src="" alt="validate status"/></td><td><a href="" false;" id="pubForm:pubTable:_id13" class="publication_select">testcode4</a></td><td>testname4</td></tr><tbody></table>

 

The publicationsBean backing bean has the following setters/getters:

 

  public DataModel getPublicationModel()
  {
    if (this.publicationModel == null)
    {
      this.publicationModel = new ListDataModel();
    }
    if (this.sortablePublications == null)
    {
      this.sortablePublications = new SortablePublicationList(loadPublications());
    }
    this.publicationModel.setWrappedData(this.sortablePublications.getPublications()); <--- so I just put a list of Publications in the DataModel
    this.publicationModel.addDataModelListener(new DataModelListener()
    {
   public void rowSelected(DataModelEvent e)
   {
    System.out.println("row selected:" + e.getRowIndex()); <----- clicking on a link in the table activates this for the whole column?!
   }
    });
    return this.publicationModel;
  }
 
  public void setPublicationModel(DataModel dataModel)
  {
    this.publicationModel = dataModel;
  }

 

  private List loadPublications()
  {
    <return a List of Publication>
  }

 

  public String getSort()
  {
    if (this.sortablePublications == null)
    {
      this.sortablePublications = new SortablePublicationList(loadPublications());
    }
    return this.sortablePublications.getSort();
  }

 

  public void setSort(String sort)
  {
    this.sortablePublications.setSort(sort);
  }

 

  public boolean isAscending()
  {
    if (this.sortablePublications == null)
    {
      this.sortablePublications = new SortablePublicationList(loadPublications());
    }
    return this.sortablePublications.isAscending();
  }

 

  public void setAscending(boolean ascending)
  {
    this.sortablePublications.setAscending(ascending);
  }

 

The sorting works, as it is I'm already quite happy with the output ;-)

 

Yet! I can't get the id of selected Publication once the commandLink is pressed as there seems to be a problem with the generated ids of each row!

 

As far as I know, each id should be something like pubForm:pubTable_0:_id13, pubForm:pubTable_1:_id13, etc...?!

 

As all my rows have the same id (see the rendered table), the DataModel's getDataRow() method always returns the last item from the row (after having iterated over the whole column it seems).

 

Does anyone know what my problem could be?

 

The master/detail example from the myfaces examples does get an id per row so I'm reckoning it's still possible.

 

I tried using <x:updateActionListener property="#{publicationsBean.selectedPublication}" value="#{publication}" />, but the problem remains as the system can't differentiate between the rows...

 

Many thanks in advance for any help!!

 

Greetings,
Kris

Disclaimer: This message and any attachments thereto are intended solely for
the addressed recipient(s) and may contain confidential information. If you
are not the intended recipient, please notify the sender by reply e-mail and
delete the e-mail (including any attachments thereto) without producing,
distributing or retaining any copies thereof. Any review, dissemination or
other use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient(s) is prohibited.
Thank you.

Reply via email to