Monday, 8 August 2016

TO DELETE A ROW WITHOUT VALIDATION ERROR IN ADF

TO DELETE A ROW WITHOUT VALIDATION ERROR IN ADF :


The Solution is tested on ADF 11.1.2.4.0 version.

You may come across bug that if the the field are required to true, validation errors may hit you and it will not make you to delete or rollback the newly inserted row.  

Simple solution is to add the immediate = True for the DELETE button and you have to add resetActionListerner to the button.

But sometimes the above solution do not work.

Hence here is the alternate solution for the problem you are facing.

Step 1 :

Add following code into your backing bean of your jsf Page.

    public void customButtonActionListener(ClientEvent clientEvent) { 
          UIXCommand cb = (UIXCommand) clientEvent.getComponent(); 
          cb.broadcast(new ActionEvent(cb)); 
      }  


Step 2: Add below javascript to your jsf page.

            <af:resource type="javascript">AdfActionEvent.prototype.isValidationNeeded = function()        
            {            return !this.getSource().getProperty("superImmediate");          }                 
            function catchActionEvent(evt){         AdfCustomEvent.queue(evt.getSource(), 'customButtonAction' , null, true);         
            evt.cancel();                        
            }              
            </af:resource> 


Step 3 :

Add Client listener and Server listener to the Delete Button.

<af:commandButton actionListener="#{bindings.Delete.execute}"
                                                                  text="Remove"
                                                                  disabled="#{bindings.ReqStatus.inputValue != null}"
                                                                  id="cb8" binding="#{backingBeanScope.PSS_USERS.cb8}"
                                                                  inlineStyle="margin:0px 0px 20px 20px; font-weight:bolder;"
                                                                  visible="#{bindings.ReqStatus.inputValue == null}"
                                                                  immediate="true" partialSubmit="true">
                                                    <af:resetActionListener/>
                                                    <af:clientListener method="catchActionEvent" type="click"/>
                                                    <af:serverListener type="customButtonAction"
                                                                       method="#{backingBeanScope.PSS_USERS.customButtonActionListener}"/>
                                                </af:commandButton>

No comments:

Post a Comment

Fill free to add your comments