Get all the children components recursively for all UI Components

Problem- Need to reset all the input Components in the page on the click of a button.On first thought developer think of do this in the bean by getting the binding of the outermost layout component and then using the getChildren() method for that UIComponent.Then for all the UI components in the list,set the reset property to true.But problem here is that page contain multiple layout components. And getChildren() method would not recursively search for all the UI components (including inside the other layout components such as panelgrouplayout.


Implementation –
Its plain java.Call the method recursively.get each input Component and reset it.

// reset all the child uicomponents
private void resetValueInputItems(AdfFacesContext adfFacesContext,
                                 UIComponent component){
   List<UIComponent> items = component.getChildren();
   for ( UIComponent item : items ) {
      
       resetValueInputItems(adfFacesContext,item);
      
       if ( item instanceof RichInputText  ) {
           RichInputText input = (RichInputText)item;
           if ( !input.isDisabled() ) {
               input.resetValue() ;
               adfFacesContext.addPartialTarget(input);
           };
       } else if ( item instanceof RichInputDate ) {
           RichInputDate input = (RichInputDate)item;
           if ( !input.isDisabled() ) {
               input.resetValue() ;
               adfFacesContext.addPartialTarget(input);
           };
       }
   }
} 
 

Happy learning with Vinay Kumar in techartifact…

Reset Binding Value from InputText in Oracle ADF

Use Case – We have one jsff page and contains some inputtext .On same page there is one Save button and one Cancel button.When user came to the page and try to enter some value in input text field and user click on Cancel button, its not resetting InputText value.When user come on same page again then he can able to see my previously entered value in Input Text though user clicked on cancel.

Normal developer will wrote Action Listener on Cancel Button and wrote below code

input.resetValue() ;
adfFacesContext.addPartialTarget(input);

But its will work (reset values).Setting value in input will not work like

input.setValue(null);
or
input.setValue("");

Few developers will think, why cant we use resetActionListener. It will work for sure,but if you make autoSubmit of inputText to true, it will not work.
Reason- InputText has autoSubmit set to true, which submit the values to model immediately after updating it, resetActionListener resets values only if changes are not populated to model.

For this case use below code.Get current row and do REFRESH_FORGET_NEW_ROWS

    Row r1=vo.getCurrentRow(); 
    r1.refresh(oracle.jbo.Row.REFRESH_UNDO_CHANGES |  Row.REFRESH_FORGET_NEW_ROWS);  
or 
    r1.refresh(r1.REFRESH_UNDO_CHANGES | r1.REFRESH_WITH_DB_FORGET_CHANGES);   

Note : If you don’t need autoSubmit, you can just remove it and use resetActionListener without any bean method to undo current row changes

It will reset binding value of input text.

Happy learning with Vinay Kumar in techartifact..

Reset your Weblogic Admin console password in Weblogic server

Requirement – Reset your weblogic admin console password

Solutions –

You can reset your pwd from the command line using the following process

-> Set up the following environment variables. They are not necessary for the process itself, but will help you navigate. In this case my domain is called “ClassicDomain”. Remember to change the value to match your domain.

->Shut down the WebLogic admin server.

->$MW_HOME/user_projects/domains/base_domain/bin/ stopWebLogic.sh

->Rename the data folder.

$ mv $DOMAIN_HOME/servers/AdminServer/data $DOMAIN_HOME/servers/AdminServer/data-bakup

  • Set the environment variables.
    $  $DOMAIN_HOME/bin/setDomainEnv.sh
  • Reset the password using the following command. Remember to substitute the appropriate username and password.
    $ cd $DOMAIN_HOME/security
    $ java weblogic.security.utils.AdminAccount <username> <password> .
  • you can also get java no class def found error.then weblogic.jar is not set in the classpath.Try to set weblogic.jar in classpath

  • Update the “$DOMAIN_HOME/servers/AdminServer/security/boot.properties” file with the new username and password. The file format is shown below.
    username=<username>
    password=<password>
  • Start the WebLogic domain.
    $ $DOMAIN_HOME/bin/startWebLogic.sh

Happy Weblogic Learning with Vinay Kumar