4 Replies Latest reply on Nov 1, 2013 4:26 PM by Shahzad Ahmed Khan

    How to set updatable property of view object on runtime

    Shahzad Ahmed Khan

      Hello Gurus,

      I am new in adf and using jdev 11.1.2.3.

       

      I have two view object which has view link and they are based on entity object. In master view i have a column with the name of status. The target is if the value of status is 'active' then i want to allow add rows in detail view and if it is inactive then wants to disable adding or editing in the detail view.

       

      I don't know how to do this. I don't know how to get the other view object and how to set update able property and where to write code in entity object class or view object class.

       

      Any advice................

       

      Thanks in Advance

        • 1. Re: How to set updatable property of view object on runtime
          Timo Hahn

          There are multiple possible ways to archive this. As the VOs are in a master-detail relationship, you can opt to add a navigation method to the child back to the parent. This method can be accessed via java or groovy to allow the child access to the master row. Once the child has access you can use this to ask the master for it's status and if it's not active disable the edit and update buttons.

           

          If both master and detail are on the same page in the ui, there is an easier way. Drag the status attribute from the master table onto the page as e.g. inputText. This will create a binding for the attribute which changes if you select a row in the master table. As you don't need to inputtext, switch to the source mode of the page and delete it. This will remove the inputtext put keep the binding. Now you can use hte binding in an EL to set the disable property of other components to true like

           

          <af:commandButton text="commandButton 1" id="cb1" disabled="#{bindings.masterstatus.inputValue ne 'active'}"/>

          The button will only be active it the binding for masterstatus is active.

           

          Timo

          1 person found this helpful
          • 2. Re: How to set updatable property of view object on runtime
            Shahzad Ahmed Khan

            Thanks Timo.

            It will be work with creating new records, but what about update existing records. I am displaying detail records in table then do i have to update all the fields in table or there is some shortcut to make the whole table as read only or disabled.

             

            Thanks

            Shahzad

            • 3. Re: How to set updatable property of view object on runtime
              Timo Hahn

              No, that is not possible for the whole table. What you can do is to use a af:swticher and put the table on the page twice, once as read only table and once as editable table. Use the binding for status to switch between the two tables.

               

              Or if you only like to have the table once on the page, you have to set the disable to each of the editable components of the table.

               

              If you like you can implement this in the model layer by overwriting the isReadOnly(int) method  of the ViewObjectImpl class returning true if the parents row status in not active. Here you access the status via accessor which is created for the view link.

               

              Timo

              • 4. Re: How to set updatable property of view object on runtime
                Shahzad Ahmed Khan

                Thanks Timo.

                I think it is better to do in model layer instead of updating all text boxes. I will try to do this and let you know if i need more help.

                 

                Thank you so much.

                 

                Shahzad