myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Georg Füchsle <giofy...@googlemail.com>
Subject Re: Problems retrieving selection data from <t:datalist via actionlistener
Date Fri, 29 Apr 2011 14:42:42 GMT
Hallo Leonardo!

Thank You for Your answer and also I regret my late responding.

The facts about the tomahawk <t:dataList is very interesting. I dind'
t think about it.
In my case I suppose there is another mistake happening for 2 reasons:

1. I keep the list that is displayed in my scope via <t:saveState
.../> So I suppose the list lying behind the t:dataList will not be
calculated once more when rendering the useraction.

2. In my list I always keep users that belong to the same institute.
Also, if the list was changed (by adding or removing a user of this
institute) it should consist of users of the same institute. Now -
twice - there was displayed the right user-list, but there were
displayed the data belonging to a user of a different institute.

There is called an action that loads the user that is clicked in the
<t:datalist into a managed bean. The data of this managed bean is
displayed. This managed bean is in request scope and also cached for
this page via t:saveState.
So its looks as if the managed Beans of different Sessions get mixed.
I cannot believe. Now i increases the log-output. I hope i can learn
more, when it happens again...

regards

Georg



2011/4/25 Leonardo Uribe <lu4242@gmail.com>:
> 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 <giofyxle@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";
>>    }
>>
>> .....
>>
>> }
>>
>

Mime
View raw message