the datatable gets the datamodel for every request (until you use preserveDataModel=true for a t:datatable). Of course it depends on the backing bean how that data is loaded. If the bean does not remember what objects are loaded and simply loads again (ex: select * from table) and a new record was added to that table between the request the new record will be loaded too. If you have 10 records before you will now have 11 records. A database normally do not guarantee that the new record will be the last one.

The JSF datatable iterates through the datamodel and sets the rowdata object in every iteration to the current object of the datamodel. It doesn´t look into the pk if the object of the last request matches the current object while it decodes the request.

There are several approaches to solve this problem:

- use a parameter in a commandlink to identify the right object (bad security as you mentioned)

- use preserveDataModel=true and t:datatable if the objects are serializable (bigger request/response if client side state saving is used)

- use forceIdIndexFormula in t:datatable (haven´t used yet). See http://myfaces.apache.org/tomahawk/extDataTable.html for documentation of that feature.

Regards,

Mathias

Enrique Medina schrieb:
Hi Mathias,

What about using getRowData() and then calling your service level to refresh the object? If it has recently changed, it would be in cache, so no hits to the DB are needed... because with the solution of the hidden parameter it is also necessary to retrieve the object in every request, isn't it?

Once I heard that the use of hidden fields breaks security in the sense that you are giving everyone the possibility to know the PK of your data. What do you think about it?

Thanks.

2005/8/31, Mathias Broekelmann <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>:

    getRowData() will work too. But if the data changes between the requests
    it could be possible that getRowData() returns the wrong object. Using a
    parameter with a commandlink which identifies the selected object would
    be safer.

    Regards,

    Mathias

    Enrique Medina schrieb:
     > Just a question...
     >
     > Why do you need a parameter to the commandlink? Wouldn't it be
     > sufficient to have the datatable in your backing bean and simply
    call
     > getRowData()?
     >
     > 2005/8/31, Jesse Alexander (KBSA 21)
    <[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>
     > <mailto: [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>>>:
     >
     >     -----Original Message-----
     >     I'm a JSF total newbbie so.. I'm sorry if I'm asking
    something trivial.
     >
     >     I read a lot of tutorials on page navigation and event
    handling... but
     >     I still can't figure out how to implement a simple master/detail
     >     pages. I make a page with dataTable reading values from a
    managed bean
     >     but I can implement the passage to the detailed page?
     >     -----/Original Message-----
     >
     >     Have you checked the tutorials at: <
    http://www.jsftutorials.net/>?
     >
     >     Basically you add a command-link as a child to a column and
    pass it some
     >     identifying attribute of the current row-object as a parameter.
     >
     >     hth
     >     Alexander
     >
     >     Else join us on the IRC-channel (search the mailing-list
    archives for
     >     the coordinates)...
     >
     >



--
Mit freundlichen Grüßen

Mathias Brökelmann
Berater

PSI Information Management GmbH
Dircksenstraße 42-44
10178 Berlin (Mitte)
Deutschland
Telefon: +49/30/2801-1458
Telefax: +49/30/2801-1000
E-Mail: [EMAIL PROTECTED]
Internet: www.psi-information-management.de

Reply via email to