Hi

The problem you described here is because JSF javax.faces.UIData
default implementation depends on the rowIndex to indicate which row
is being affected by the action (for example click a link), or restore
the state of the row. I'll do a description about the problem, to give a
better idea about what's going on.

For example, suppose this list of data:

- A
- C

Now suppose between the first request and the next one when you
press the link (for C row), by some reason (other user, same user
other window, ... ), now the list is this:

- A
- B
- C

When UIData tries to know which link was clicked, it says
"... look for the second row ...", so in practice, the server assume B
was clicked, but the client clicked C.

There is a lot of solutions in JSF to deal with this problem. JSF libraries
has
overcome this issue creating its custom JSF component hierarchy
and its custom "model" interfaces (see Trinidad for example). Other
solutions include
use MyFaces Orchestra to store the model in "access" scope,
t:dataTable "preserveDataModel" property or in a future release of tomahawk
(1.1.11) use
an EL expression to identify the row and "derive" the child clientIds called
rowKey. Below
there is the description:

* - Used to assign a value expression that identify in a unique way a row.
This value
   will be used later instead of rowIndex as a key to be appended to the
container
   client id using getDerivedSubClientId() method.
*
The only disadvantage of use "rowKey", is that in some way the
primary key or a derivate of your data is output on the html, and somebody
could
not want that by some special reason. Note the default strategy used for
years in UIData using rowIndex hides that information.

regards,

Leonardo Uribe

2011/4/8 Georg Füchsle <giofy...@googlemail.com>

> Hallo!
>
>
> I use Jsf 1.2 with Tomahawk and Facelets.
>
> On a page listing users that belong to a company, I use <t:datalist ..>
> To edit one user, I call an actionListener, that retrieves the id of
> the selected user.
>
> This works since some years. Now it happens sometimes that the
> selection of the user finds a userid of a user that belongs to another
> company as listed.
>
> This is really bad... :-(
>
> Is there any advance to replace the actionlistener with
> <f:setPropertyActionListener ...?
> Has anybody an idea?
>
> Thanks!
>
>
>
> here is may actual code:
>
>
>
>
> <table>
>        <t:dataList     id="tablebediener"
>                        rowCountVar="macCount"
>                        value="#{mbBedienerVerwaltung.bedienerEB}"
>                        var="bediener"
>                        rowIndexVar="index">
>                <tr>
>                        <td     class="tabA_rahmen"
>                                style="padding-left: 5px; width: 310px;">
>                                <div>
>                                        <t:commandLink  styleClass="aLink"
>
>  value="#{bediener.bedAnzeigeName}"
>
>  action="#{mbBedienerVerwaltung.edit}"
>
>  actionListener="#{mbBedienerVerwaltung.mandantSearch}">
>                                        </t:commandLink>
>                                </div>
>                        </td>
>
>                        <td>...</td>
>                ...
>                </tr>
>
>        </t:dataList>
> </table>
>
>
>
>
> Here my backing bean:
>
>
>
> public class MbBedienerVerwaltung implements Serializable
> {
>        private List<BedienerData> bedienerEB=null;
>        private Integer idBediener;
>
>
>
>    public void mandantSearch(ActionEvent event)
>    {
>        this.idBediener = 0;
>        try
>        {
>            BedienerData bed = null;
>            UIData ob = JsfUtils.getUIDataParent(event);
>            Object tmp = ob.getRowData();
>            bed = (BedienerData) tmp;
>            this.idBediener = bed.getBedId();
>
>        }
>        catch (RuntimeException e)
>        {
>            log_tech.warn("mandantSearch(): Die BedienerId kann nicht
> bestimmt werden! Der Bediener kann nicht editiert werden");
>            this.idBediener = null;
>        }
>
>    }
>
>    public String edit()
>    {
>        if ((mbBediener != null))
>        {
>                // retrieve Backingbean for User
>                MbBediener mbBediener = JsfUtils.getMbBediener();
>                // read Userdate for id from Database
>            mbBediener.read(idBediener);
>            return "edit";
>        }
>        // Error
>        return "error";
>    }
>
> .....
>
> }
>

Reply via email to