Thursday, 26 March 2015

How to disable RichInputText in an ADF page programmatically

Hi, it is Mostafa Amine here, this is my First blog Ever, i always wanted to blog but i never had or made time for that, so here i am writing my First Blog entry Ever, hope it will be Helpful to Everyone who reads it or stumbles upon it :)






so a few days ago i wanted to disable a RichInputText and a RichCommandToolbarButton programmatically from a Managed bean, all i could find on the internet was CSS and JQuery solutions, so here is a solution for those who donot want to go through CSS and JQuery or who are using page Fragments (.jsff) like me




to disable components like (RichInputText , RichCommandToolbarButton  or RichSelectBooleanCheckbox), you can bind that component that you want to disable programmatically and then make a new  (RichInputText , RichCommandToolbarButton  or RichSelectBooleanCheckbox) based on your scenario, then set the property disabled  of this component to True and then assign your component (that you want to disable) to that newly created disabled component, below is the code of how to do so



        RichInputText newInputText= new RichInputText();

        newInputText.setDisabled(true);
       set<YourInputTextName>(newInputText);


      RichSelectBooleanCheckbox newChckBox = new RichSelectBooleanCheckbox();

      newChckBox .setDisabled(true);
     set<YourChckBoxName>(newChckBox );




     RichCommandToolbarButton newCmdBttn= new   RichCommandToolbarButton();

     newCmdBttn.setDisabled(true);
     set<YourCmdBttnName>(newCmdBttn);



you might ask, why would not you just set the binding's disabled property directly instead of making a new UI component n setting its disabled property, i found that this method doesnot always work, specially if you want to disable/enable your component in the constructor if your bean, you have to use this method.






No comments:

Post a Comment