Monday, April 9, 2007

Create, Edit and Delete operations in ADF Faces af:table component

I have received questions for my previous post - Creating new row using CreateInsert operation, about how to extend described sample with Edit functionality and how to make table read-only. I have extended published sample and want to describe updated functionality in this post.

Datasource and business logic are used the same as before. New features of extended sample - EditableTable.zip:
  1. Table is read-only, however newly created row is shown in edit mode
  2. Editing for selected row is enabled
  3. Delete operation is added
To make existing rows read-only and newly created row editable until save, you must change ReadOnly property value for each af:inputText component contained in af:column. Set ReadOnly property value to - #{row.JobId != null}. This means, if row isn't empty it will be displayed as read-only. In other case, if row is empty it will be displayed as editable:


After 'Save' button is pressed, newly entered row is stored in the database:


Second feature - selected row editing. To enable row editing I have used technique described in Frank Nimphius's blog - ADF Faces: Conditionally disabling an af:tableSelectOne row for selection. You should create ActionListener for Edit button, created ActionListener will store selected row ID into managed bean atttribute - enableEditing. Managed bean method code for enableEditing attribute, this code compares current row with selected row:


For each af:inputText component contained in af:column, change ReadOnly property value to #{row.JobId != null && !valueHolder.enableEditing}. Edit functionality:


Delete operation is developed by making simple drag-and-drop from Data Controls pallete to ADF Faces af:table component.


When running sample application, don't forget to add adf-faces-impl.jar and jsf-impl.jar to application's WEB-INF\lib directory.

94 comments:

  1. This is a nice example.
    I was trying to extend this example by little to redisplay the value of jobid in another newly created column with an outputText field.
    I have set autosubmit of jobid to true and partial trigger to newly created column field id.
    Created value change listener method in ValueHolder bean, which will display new value of the field when value changes.

    The Problem is , while in new record creation, the VCE is firing only once and not firing again.

    Can you please give some guidelines on how to do this?

    Thanks in advance

    ReplyDelete
  2. Hi,

    If you can send extended sample to me by email, I could look into it. Without code it is hard to say what is wrong.

    Regards,
    Andrejus

    ReplyDelete
  3. That's a great job if you can use TopLink *commit* capabilities ... but mine is not the case.

    I have a table "based upon" a bean method, accessed through a Business Delegate class, which returns a list of DTO objects.

    Thanks to your tips I can show editable fiels when edit-mode is enabled, but I have no means to save the data since I don't manage to get the data from the inputtext components.

    Obviously I cannot use the getValue() method for the controls since the actual created controls will have no bindings I could use.

    I discovered also I cannot use variables and attributeValues (i.e. inputValue) to get data from the text fields.

    Next, I tried "switcher" controls, one for each column, displaying *real* rows only if not in edit mode (and showing a "standard" inputtext in edit-mode), but - even using this technique (with variables and attributeValues) - I lost ;).

    Can you please give me some hints or, better, show me a working example ?

    Hoping all is clear,
    I thank you in advance.

    ReplyDelete
  4. Hi Antonio,

    You can access and get the data contained in ADF Faces table row, through iterator associated with the table.

    Regards,
    Andrejus

    ReplyDelete
  5. First of all I thank you.

    Do you mean I can obtain the *new* values (entered by the user) through the iterator associated to the table ?

    I will try that, but it sounds strange. If this is true the #{row} variable is updated to reflect the changes the user made into editable-fields. Do I understand ? :)

    I'll let you know.
    Thanks Again

    Antonio

    ReplyDelete
  6. The previous post is a good example of my bad english ;)

    Especially "Do I understand" ... I mean "Have I understood" instead.

    Sorry.

    ReplyDelete
  7. Hi Andrejus,
    I need your help ... that does not works.

    This time I show my code:

    <af:table value="#{bindings.loadAllSegnalazione1.collectionModel}"
    var="row"
    rows="#{bindings.loadAllSegnalazione1.rangeSize}"
    first="#{bindings.loadAllSegnalazione1.rangeStart}"
    emptyText="#{bindings.loadAllSegnalazione1.viewable ? 'No rows yet.' : 'Access Denied.'}"
    selectionState="#{bindings.loadAllSegnalazione1.collectionModel.selectedRow}"
    selectionListener="#{bindings.loadAllSegnalazione1.collectionModel.makeCurrent}"
    binding="#{backing_table_TestTable2.table1}"
    id="table1" banding="row">
    <af:column sortProperty="IDSegnalazione" sortable="false"
    headerText="IDSegnalazione"
    binding="#{backing_table_TestTable2.column1}"
    id="column1">
    <af:inputText value="#{row.IDSegnalazione}" simple="true"
    required="#{bindings.loadAllSegnalazione1.attrDefs.IDSegnalazione.mandatory}"
    columns="#{bindings.loadAllSegnalazione1.attrHints.IDSegnalazione.displayWidth}"
    binding="#{backing_table_TestTable2.inputText2}"
    id="inputText2"
    readOnly="#{ !backing_table_TestTable2.editEnabled && row.IDSegnalazione != null}"/>
    </af:column>

    :
    :

    <f:facet name="selection">
    <af:tableSelectOne text="Select and"
    binding="#{backing_table_TestTable2.tableSelectOne1}"
    id="tableSelectOne1">
    <af:commandButton text="Edit"
    binding="#{backing_table_TestTable2.cmdEdit}"
    id="cmdEdit"
    disabled="#{backing_table_TestTable2.inEditMode == true}">
    <af:setActionListener from="#{row.IDSegnalazione}"
    to="#{backing_table_TestTable2.currIDSegn}"/>
    <af:setActionListener from="#{true}"
    to="#{backing_table_TestTable2.inEditMode}"/>
    </af:commandButton>
    <af:commandButton text="updateSegnalazione"
    binding="#{backing_table_TestTable2.cmdSave}"
    id="cmdSave"
    disabled="#{backing_table_TestTable2.inEditMode == false}"
    actionListener="#{backing_table_TestTable2.ProvaUnAttimo}">
    <af:setActionListener from="#{row.IDSegnalazione}"
    to="#{backing_table_TestTable2.currIDSegn}"/>
    <af:setActionListener from="#{false}"
    to="#{backing_table_TestTable2.inEditMode}"/>
    </af:commandButton>
    </af:tableSelectOne>
    </f:facet>
    </af:table>


    And this is the code in "#{backing_table_TestTable2.ProvaUnAttimo}" :


    public void ProvaUnAttimo(ActionEvent actionEvent)
    {

    System.out.println("ReadOnly: " + getInputText2().isReadOnly() ); // False

    DCBindingContainer dcBind = (DCBindingContainer) ADFUtils.findBindingContainer(getBindings(), "table_TestTablePageDef");
    DCIteratorBinding dcIter = dcBind.findIteratorBinding("loadAllSegnalazioneIter");

    Row riga = dcIter.getCurrentRow();
    Long info2 = (Long) riga.getAttribute("IDSegnalazione");
    System.out.println("Iterator: " + info2); // Always original db value *NOT* what I've inserted

    System.out.println("textValue: " + getInputText2().getValue()); // Even Here I get the original value - not the inserted one

    }

    And, finally, that's the code I "copied" from your article:

    public boolean isEditEnabled()
    {
    // Restituisce TRUE solo per la riga correntemente selezionata.

    // Ottiene l'ID della segnalazione attualmente selezionata
    FacesContext fc = FacesContext.getCurrentInstance();
    ValueBinding vb = fc.getApplication().createValueBinding("#{row.IDSegnalazione}");
    Long IDSegn = (Long) vb.getValue(fc);

    // Se l'ID è uguale a quello della riga che era selezionata quando è stato
    // premuto il pulsante "Modifica" ... allora restituisci true.
    if ( currIDSegn != null )
    {
    this.editEnabled = ( this.currIDSegn.equals( IDSegn ) );
    return this.editEnabled;
    }

    return false;
    }


    Please help me.

    ReplyDelete
  8. What makes me angry is that if I leave *always* "ReadOnly = false" (i.e. at Design time), I can read inputText values with no problems.

    Have you any idea ?
    Thank you again

    ReplyDelete
  9. I found the problem ... at least regarding the solution with the switcher control.

    I missed one *important* thing: the bean used for storing the properties used for EL (i.e. Expression Language) *NEEDS* to be of type *session*.

    Thank you !

    ReplyDelete
  10. Recently I received a question about how to insert new row at the bottom of the table. To achieve this, create method action for Create button in backing bean class and put similar code:

    BindingContainer bindings = getBindings();

    DCIteratorBinding dcib = (DCIteratorBinding) bindings.get("JobsView1Iterator");
    RowSetIterator iter = dcib.getRowSetIterator();
    Row newRow = iter.createRow();
    iter.insertRowAtRangeIndex(iter.getRangeSize() - 1, newRow);
    iter.closeRowSetIterator();

    Regards,
    Andrejus

    ReplyDelete
  11. Hi,

    In 11g, ValuBinding is deprecated..It seems. Then what is the alternative?

    ReplyDelete
  12. Hi Andrejus,

    While using the following code in Jdeveloper I am getting deprecated mark on both ValueBinding class and createValueBinding method. I dont know whether JDev 11g has provided any alternative way to access value binding. Do you have any Idea on that.Thanks in advance.

    ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{row.rowKeyStr}");

    ReplyDelete
  13. Hi,

    It's strange, haven't faced this in JDeveloper 11g. I will look into it and post my findings here.

    Thanks,
    Andrejus

    ReplyDelete
  14. Hi, I was trying to extend this example with :
    -Editing for selected row is enabled
    But, i can't Save with Action Commit when EditingEnabled
    My Code is same the exam with #bindings.Commit.Excute for SaveButton and in PageDef
    But , I use EJB Datacontrol for a Database Connection ,and don't find
    Operation with Commit and RollBack
    I think , this is cause for i can' COMMIT ...
    Can you Help me, Thanks ^_^

    ReplyDelete
  15. Hi,

    You can use 'Persist' instead of 'Commit' in EJB case.

    Regards,
    Andrejus

    ReplyDelete
  16. Hi,
    I want use Validators or Converters in Table with a Column input when Edit or Creat ,Ex
    Table has 3 Columns :
    - 2 Columns output for Type : Number,date, Boolean , and Value
    - A Column input for Edit value, and must Check Type right.
    Do you have a example ?
    Thanks !

    ReplyDelete
  17. Hi,

    No, currently I don't have such sample. But, I will develop and post it in the future.

    Regards,
    Andrejus

    ReplyDelete
  18. Hi! I have a problem with "Edit functionality".

    With the following code, when you click "Edit" all registrys are enabled, and when later, you click "Save" the data doesn't update its values.

    The code is the following:


    public boolean isEnabledEditing(ActionEvent actionEvent) {
    FacesContext ctx = FacesContext.getCurrentInstance();
    Application app = ctx.getApplication();
    ValueBinding bind = app.createValueBinding("#{row.CodProvincia}");
    String codProvincia = (String)bind.getValue(ctx);
    this.enableEditing = this.getSelectedCodProvincia().equals(codProvincia);
    return this.enableEditing;
    }

    af:commandButton text="Edit"
    disabled="#{backing_prueba.createAction}"
    actionListener="#{backing_prueba.isEnabledEditing}"

    af:setActionListener
    from="#{row.CodProvincia}"
    to="#{backing_prueba.selectedCodProvincia}"/
    /af:commandButton

    Any ideas?
    Thanks in advance,
    Jaime.

    ReplyDelete
  19. Hi! I have a problem with Edit functionality.

    The problem is, when I click the Edit button, all registrys are enabled, and when I click on Save, the data are no updated,


    The code in JSP is the following,

    af:commandButton text="Edit"
    disabled="#{backing_prueba.createAction}"
    actionListener="#{backing_prueba.isEnabledEditing}"

    af:setActionListener
    from="#{row.CodProvincia}"
    to="#{backing_prueba.selectedCodProvincia}"/
    /af:commandButton

    The code in backing is the following,

    public boolean isEnabledEditing(ActionEvent actionEvent) {
    FacesContext ctx = FacesContext.getCurrentInstance();
    Application app = ctx.getApplication();
    ValueBinding bind = app.createValueBinding("#{row.CodProvincia}");
    String codProvincia = (String)bind.getValue(ctx);
    this.enableEditing = this.getSelectedCodProvincia().equals(codProvincia);
    return this.enableEditing;
    }

    Thanks in advance,
    Jaime.

    ReplyDelete
  20. Hi Jaime,

    You should put something like this - #{row.JobId != null && !valueHolder.enableEditing} on af:inputText component available in column. Put it to ReadOnly property.

    I have used the same functionality in this sample.

    Regards,
    Andrejus

    ReplyDelete
  21. Hi Andreus!

    When I edit a registry, I change the value correctly, but when I click commit, it doesn't updates the value.

    Could you help me?
    Thanks,
    Jaime.

    ReplyDelete
  22. Hi Jaime,

    I guess, you forgot to drag and drop Commit operation on your Save button. You need to put Commit operation available in Data Model on Save button. Don't forget to modify Disabled property of your Save button after Commit will be dragged and dropped.

    Regards,
    Andrejus

    ReplyDelete
  23. Hi Andrejus!
    I have checked commit operation, and I pressed Save button during Edit operation (after modify values).

    It doesn't works?
    Any suggestion?
    Thanks,
    Jaime.

    ReplyDelete
  24. More Tracks about the problem....

    I have do the next test:

    I have eliminated the readonly value, and modify values works correctly, using edit and commit.

    Any ideas?

    ReplyDelete
  25. More Tracks about the problem....

    I have do the next test:

    I have put a breakpoint in doDML operation, and when I create a registrys an later, and later commit, it goes to doDML and updates DDBB.

    But when I modify the registry, and later commit, it doesn't goes to doDML operation.

    Please help!!


    Any ideas?

    ReplyDelete
  26. Hi,

    May be you are using read-only View object? Commit operation is quite simple in ADF, it should work in fact without problems...

    Regards,
    Andrejus

    ReplyDelete
  27. Hi,
    I have the same problem as jaime carmona, when i create a new row and then click commit it is correctly inserted into the db, but when i edit and then click commit theres no change.
    One question, the commit action saves all the rows in the table or only the one selected?

    Thanks in advance

    ReplyDelete
  28. Hi,

    I have tested my sample, it works ok in Edit case also. Can you explain your steps?

    Commit action saves actually all modified rows.

    Regards,
    Andrejus

    ReplyDelete
  29. Of course, I have everything like your example except for the save button, and maybe theres the problem, the Data Control Palette doesn´t show the commit operation, so i created an ActionListener for that button like this:
    public String commandButton11_action() {
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    bindings.getOperationBinding("Commit");
    Object result = operationBinding.execute();
    System.out.println(result.toString());
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    }
    return null;
    }

    Maybe I have to enable the commit operation but I haven´t found out how, the thing is I´m giving maintenance to a web and I´m a newbie in adf XD, so I don´t know how to do that

    Thanks again!

    ReplyDelete
  30. Hi Cristina,

    You code looks good. I think you have created Commit operation declaration in page-definition, yes?

    In Data Control, Commit operation is available as general operation, it is not associated with any View object.

    Regards,
    Andrejus

    ReplyDelete
  31. Great job Andrejus...
    I Had the same problem with the edit option, the back bean should be defined as session scoped, eliminate the bindings property in the back bean and use:

    private DCBindingContainer getBindingContainer(){
    FacesContext fctx = FacesContext.getCurrentInstance();
    Application app = fctx.getApplication();
    ValueBinding vb = app.createValueBinding("#{bindings}");
    DCBindingContainer dc = (DCBindingContainer) vb.getValue(fctx);
    return dc;
    }

    ...
    DCBindingContainer dc = getBindingContainer();
    OperationBinding oper = (OperationBinding) dc.get("Commit");

    ReplyDelete
  32. Hi Andrejus,

    How to bypass validation if user press create? But I want those validator back into bussiness while user tries to submit the form.

    Regards,
    Ghosh

    ReplyDelete
  33. Hi,

    When user press Create there just new empty row is opened. Validation is invoked when Commit is pressed.

    Regards,
    Andrejus

    ReplyDelete
  34. Hi Andrejus,

    I am working on ADF. I have a table layout which has a “create” button. When I click on this button, it creates 3 empty rows.
    When I enter only one row and leave the rest of 2 rows as blank and try to commit the transaction, I am getting the following error:
    “JBO-26018: Cannot insert a new row with no attribute set in entity”

    Can you please guide me on this?

    Thanks,
    Lakshmi.

    ReplyDelete
  35. Hi,

    It looks like correct behavior for validation.

    You can check my post with functionality that allows to insert multiple rows - Create multiple rows in Oracle ADF.

    Regards,
    Andrejus

    ReplyDelete
  36. Thanks Andrejus. I follwed your sample and created my application in the similar way. I created 3 empty rows and i entered only one. When i commit, i dont want to see any error message for the empty rows. It should only commit the row i entered. Is this acheivable?

    Thanks Again, Lakshmi.

    ReplyDelete
  37. Hi Lakshmi,

    You can create action method for Save button in Backing bean. In this method you can acquire table iterator and during Commit process you can remove empty row. So, in such was validation rule will not be activated.

    Regards,
    Andrejus

    ReplyDelete
  38. Hi Andrejus,

    I am acquiring the table iterator using DCIteratorBinding Class. DCIteratorBinding dcib = (DCIteratorBinding) bindings.get("BFDetails1Iterator"); How can i identify an empty row from here? Can i exclude the validations for an empty row rather than removing it? if so, can you please help me?
    Thanks,
    Lakshmi.

    ReplyDelete
  39. Hi,

    If you will exclude validation for empty row, you will get database error, because data will be wrong.

    You can remove row from iterator. You can check first 3 rows added to iterator and if required value in some row is missing you can remove this row.

    Regards,
    Andrejus

    ReplyDelete
  40. Dear Mr. Andrejus Baranovskis ,
    Suppose I have clicked on Create or Update button and then I decide to come out of create / edit mode, what should be my code?

    Thanks in advance..

    ReplyDelete
  41. Hi,

    It is implemented in my sample actually. You can download code.

    Regards,
    Andrejus

    ReplyDelete
  42. Hi Mr.Andrejus Baranovskis,
    Thanks for the prompt reply,
    Sorry, I should have specified my set of technologies,
    I am using EJB3.0 and ADF faces on jDeveloper 10g. Here I do not have rollback operator.
    And I am not implementing in-line editing , instead, I am selecting a row in the table and on click of 'Submit' button, the row details are shown in a form and I am adding 'Merge' button to the form to update the data. For adding a new record, I click on the 'Create' button, it will show up a blank form, I add the data and click on 'Persist' button.
    In case I want to abort the above two operations, what I shouls do..

    Thanks in advance..

    ReplyDelete
  43. Hi,

    After you have executed Persist, it will be not possible to make Rollback, since data is committed.

    However, you also can use Rollback in EJB 3.0, it will work until transaction is not committed.

    Regards,
    Andrejus

    ReplyDelete
  44. I need a to drag and drop same row into another row, overwriting it a into a new row..
    please can anyone help

    ReplyDelete
  45. Hi,

    Can you specify your case little bit more?

    Thanks,
    Andrejus

    ReplyDelete
  46. I figured out how to get the new row at the bottom of the table when returned rows is less than the range length but I can't get the table to show this as the selected row. When I set the iterator current row to the new row it has no bearing on the table.

    I also would like to know if there is a way around the timing issue if the fetched row count is greater than the range size so the new row could be put at the end of the collection instead of in the middle of it.

    Thanks for any help.

    ReplyDelete
  47. Hi,

    You should use similar code to insert new row at the bottom of the table:

    BindingContainer bindings = getBindings();

    DCIteratorBinding dcib = (DCIteratorBinding) bindings.get("JobsView1Iterator");
    RowSetIterator iter = dcib.getRowSetIterator();
    Row newRow = iter.createRow();
    iter.insertRowAtRangeIndex(iter.getRangeSize() - 1, newRow);
    iter.closeRowSetIterator();

    Regards,
    Andrejus

    ReplyDelete
  48. Thanks for the answer, but what I meant was...
    RangeSize = 10; RowCount = 15;
    I would like to shift the table to display rows 11-15 (10-14 zero based) and then add the new row after the last row on this 2nd page of values.

    I can get the table to scroll by doing a queueRangeChangeEvent for it, the problem is that the insert row happens before the table has processed the range change event.

    Also the column with the radio button in it is not selected for the new row.

    Thanks for your help.

    ReplyDelete
  49. Hi,

    I understood you now, I will take a look into this until end of week. If I'll find solution, will post it here.

    Regards,
    Andrejus

    ReplyDelete
  50. Thanks Andrejus !!!

    I was stumped on how to create new rows in ADF table until I read this.

    Do you have a more complex example on master detail create, edit, delete. One involving dropdowns for selecting values?

    Also How can we change the master to be a drop down list instead of a table or form?

    Thanks for the advice.

    Husain

    ReplyDelete
  51. Hi Andrejus,

    I did went through your examples.
    However the technology we use is Faces, EJB + Toplink.
    Currently I have created a table and added a dynamic dropdown (which fetches name and Id from another table). I have set the value of the drop down to be #{row.apiId} as in table. And still it does not show the correct value in the dropdown for the table rows. All dropdowns show blank values.
    I checked the types of Id in both ADF table and Dropdown value and they are same.

    What have I missed?

    Thanks

    ReplyDelete
  52. Hi,

    there is ReadOnly preperty set to #{row.JobId != null && !valueHolder.enableEditing}.
    Is it possible to do the same thing in af:table, because there is only to choose between true and false.

    Thanks

    ReplyDelete
  53. Hi,

    No actually, it must be set for af:inputText component available in af:column.

    Regards,
    Andrejus

    ReplyDelete
  54. Hi,

    I need to set inputText readOnly property to be true only for the values that are also in some other table. How could I do it?
    E.g. in SQL it would be:
    SELECT t1.v1 FROM table1 t1 WHERE v1 IN (SELECT t2.v1 FROM table2 t2)

    These values should be readOnly.

    Thanks in advance

    ReplyDelete
  55. Hi,

    You can execute custom View object from isEnableEditing() method and decide if row must be editable or read-only.

    Regards,
    Andrejus

    ReplyDelete
  56. Hi, thank you for your answer above.

    How can I pass the value from current row to custom VO. I trie something like this but it doesn't work.

    public boolean isEnableEditing() {
    FacesContext fctx = FacesContext.getCurrentInstance();
    ApplicationModule am = ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
    ViewObject vo = am.findViewObject("SubmodulView1");

    String submodulNumber = (String)vo.getCurrentRow().getAttribute("SubmodulNr");
    OperationBinding oBinding = (OperationBinding)fctx.getApplication().createValueBinding("#{bindings.ExecuteWithParams}").getValue(fctx);
    oBinding.getParamsMap().put("submodulNr", submodulNumber);
    oBinding.execute();
    vo = am.findViewObject("SubmodulUTabliciView1");

    int nrOfModules = 0;
    nrOfModules = vo.getRowCount();

    if (nrOfModules == 0){
    cellReadOnly = false;
    }
    else{
    cellReadOnly = true;
    }

    return cellReadOnly;
    }

    This way doesn't work. It always takes the value of the first row.

    Thanks a lot, again

    ReplyDelete
  57. Hi,

    You can use the same code available in isEnableEditing() function from my sample. For example: ValueBinding bind = app.createValueBinding("#{row.JobId}"); will access JobId attribute value from each row.

    Regards,
    Andrejus

    ReplyDelete
  58. Thank you very much

    ReplyDelete
  59. Hi,

    thanks a lot for your replies and your time.

    I did it how you said and it works fine, except for two things. First one. On form load ValueBinding bind = app.createValueBinding("#{row.JobId}"); accesses every row that many times how many rows is there in a table.
    So I get the following situation. Let's say there are 3 rows in a table. I put the following code in managed bean:
    ValueBinding bind = app.createValueBinding("#{row.JobId}");
    String job = (String)bind.getValue(ctx);
    System.out.println(job);
    I get following outcome:
    job1
    job1
    job1
    job2
    job2
    job2
    job3
    job3
    job3

    Second thing is on every click in a table managed bean is invoked. Is there any way to stop this kind of behavior.

    ReplyDelete
  60. Hi,

    You can use selection listener to control described behavior when some row is selected.

    Regards,
    Andrejus

    ReplyDelete
  61. Hi Andrejus Baranovskis...

    First of all Thank you very much for your Efforts to Sharing your best knowledge with us..

    This is very nice Example..

    But Andrejus Like others I'm also facing the same problem in Commit button after Editing all Input Texts in Editable Row..

    so you had suggested that it is happening because of Bean Scope... your application is in Session scope...that's why it is working.. but if we change the scope of bean to request scope...then the problem arrives..

    But I don't know much about sessions..
    So Andrejus...right now i have over thousand lines of code i backing beans and over 500 ADf Components on me page...and right now the scope is request..

    If I change the scope of my Bean class then is their any prom which i can face after changing it...

    Or do you know any other alternative to do the Commit button work in the Request scope?

    Please help me...

    and What is Request and Session Scope...Can i change the this any time in Production period of application...?

    Thanks in advance Andrejus..

    ReplyDelete
  62. Hi,

    Scope means how long actual Bean lives. If it reuest, this means from request to request. If session, this means Bean object is created ones for session. You can change bean scope in faces-config.xml, in Managed Bean section.

    Regards,
    Andrejus

    ReplyDelete
  63. The link to Frank's Conditionally disabling an af:tableSelectOne row for selection blog is broken.

    Can you please provide some clue about the Frank's technique you've referred in your article to add Edit functionality.

    I am new in this field and therefore facing some difficulties in implementing Edit functionality.
    For instance my selectedId property always remains null in backing bean and I get an exception whenever I refer to it.

    Thanks!

    ReplyDelete
  64. Hi Amir,

    I just refering to Frank post, but I have implemented the same thing in my sample. You can find it in isEnableEditing() method.

    Regards,
    Andrejus

    ReplyDelete
  65. Hi Andrejus,

    I am using ADF Faces Core components.

    I have a field selectedId in ValueHolder bean. I also have setSelectedId and getSelectedId methods there.

    I have inserted setActionListener with my Edit button:
    From: #{row.Id}
    To: #{ValueHolder.selectedId}

    On adding some System.out.println messages in my setters, getters and isEnableEditing method, I find that selectedId is always null. It seems to me that setSelectedId method is not called, since its debugging message isn't printed. So getSelectedId is always returning null and therefore isEnableEditing is always sending false to enableEditing attribute.

    ValueHolder has session scope.

    What can be the problem?

    Thanks!

    Amir

    ReplyDelete
  66. Hi

    I have found where the problem was. In your example the Edit button is in tableSelectOne component, whereas I was trying to display the buttons in footer. Therefore the #{row.myField} wasn't visible to the button. Now it is setting the correct value in my selectedId field.

    Regards,

    Amir

    ReplyDelete
  67. I am gettting the same error which is posted by GHOSH on 17 september 2007.That is both class binding,method CreateValueBinding are deprecated in Jdeveloper11g.

    How can these be replaced in jdev 11g

    ReplyDelete
  68. Hi,

    Pls. check my new post - http://andrejusb.blogspot.com/2007/11/jdeveloper-11g-create-edit-and-delete.html

    Look for text: "What's the difference here? First thing - since ValueBinding is deprecated, I'm using ValueExpression to access column value in a table. And second - I'm using oracle.jbo.server.ViewRowImpl to hold selected row."

    Regards,
    Andrejus

    ReplyDelete
  69. Hi Andrejus,

    I am quite new to ADF and I found this sample really helpful.

    I was facing the same problem with Edit button, but as it was written before it was due to attribute scope of Manage Bean, changing it to session helps.

    Tanks.

    Martin

    ReplyDelete
  70. How can i add buttons in every row of the table and on click to delete that row

    Thanks

    ReplyDelete
  71. Hi I have tried this top example, to edit the selected record. however once i hit the edit button i get an error...

    500 Internal Server Error
    javax.faces.el.ReferenceSyntaxException: row.UgmCode !=null && !valueHolder.enableEditing

    any ideas what im doing wrong??

    i have the same valueholder.java file and ammened the jobID to UgmCode.

    thanks in advance

    ReplyDelete
  72. Hi,

    If a user selects a field and then presses the button to edit, the field then comes editable, which works fine. However if the user then decides that field doesnt not need editing and just selects another field. The original field is still in edit mode unless the user selects save first even though nothing has been changed (a user is unlikely to do this).

    any ideas for a solution please??

    thank you in advance.

    ReplyDelete
  73. Hi,

    Try to use Rollback button functionality.

    Andrejus

    ReplyDelete
  74. Please can you give me an example on how to use the rollback in this situation.

    Thanks

    ReplyDelete
  75. If you are working with 11g, there is clickToEdit option supported by default. Its one of table component options.

    Regards,
    Andrejus

    ReplyDelete
  76. Sorry i am working will 10g.
    Is there a way to do this without using a 'Cancel 'link or button for executing the rollback.

    id just like it so if the user selects onto another row the previous row becomes uneditable.

    Thanks

    ReplyDelete
  77. Please can you give me an example on how to use the rollback in this situation for 10g?

    Thanks

    ReplyDelete
  78. It should work same as Save, you can apply same code to make row read-only.

    Andrejus

    ReplyDelete
  79. Do you mean without the user having to press a 'cancel' button/link?

    the save works on a commit button.

    So how can i use the same code when i dont want either a button/link.

    thanks

    ReplyDelete
  80. I dont think its possible. Probably you can do this only with Java Script.

    ReplyDelete
  81. Is it possible when the row is in edit mode that all other rows are disabled, so are unable to be selected?

    This can then force the user to either Save or Canel their action to Edit the row. I can try and implement that only them two buttons are displayed when in the edit mode.

    So is it possible to also hide buttons when in edit mode and replace them with other buttons for example...

    When in normal mode Add, Delete, Edit and Save are displayed.
    However when in edit mode id like to replace the Add, Delete buttons with just the Save and Cancel. So not space is wasted. is this possible?

    Thank you

    ReplyDelete
  82. Yes, you can try to use Visible attribute, instead of using Disable attribute.

    Andrejus

    ReplyDelete
  83. how about making the other fields non selectable while in edit mode. Once the save/cancel is pressed all fields are selectable?

    Help would be greately appriciated :)

    Thanks

    ReplyDelete
  84. You can override selection listener, and programatically make current row disabled, when user clicks on another row.

    Andrejus

    ReplyDelete
  85. I am having some trouble with the enableEditing property. After debuggin i have realized that my application crashes on the following line
    String jobId = (String)bind.getValue(ctx);

    Instead of using a string for jobId I am using an integer, is there any way that could be the issue?
    Thanks in advance

    ReplyDelete
  86. Yes, you need to change a type to Integer.

    Andrejus

    ReplyDelete
  87. This comment has been removed by the author.

    ReplyDelete
  88. HI,
    I tried this, I works fine for me. Now, My requirement is, in a table I have 3 columns, 2 are output text (auto populated), 1 field is input Text, your code works fine. In that two auto populate fields, one is from database, when I auto populate that particular field, the input text field becoming non-editable. What is the solution for this?
    Here is my code of the input text :




    Kindly help.

    ReplyDelete
  89. Hi Andrejus!!!

    Thanks for Sharing your knowledge about ADF. Now I want some Idea from you, as I want to generate(or createInsert) new row without clicking any button but instead from any event listner Like value Change listner of inputText for e.g as we do in jsp pages with javascript or jquery using onchange/blur events to add a new row in the table, so Any Idea how to achieve the same functionality here in adf and jsf. Also i want my input values in the table from some other viewobject and I want to store the value in another table on committing or clicking the save button.

    ReplyDelete
  90. You can insert new row in ADF easily from value change listener - you can do Partial Submit to refresh the table - it will display newly inserted row.

    Andrejus

    ReplyDelete