Sunday, March 31, 2019

How to enable and disable a table column based on another table column value in OAF

How to enable and disable a table column based on another table column value in OAF

 
Today I am going to tell you how to enable and disable a table column based on another table column value in OAF. E.g. We have one scenario where we have one column as recommended reason which is a drop down. There are 4  values in it. We have to fulfill below conditions:
 
1) If reason is selected as TONER from drop down, then RMA Number and Customer comments field should be disabled.
2) If reason is selected as RETURN from drop down, then RMA Number/Copies column should be enabled and required field with a tip message as "Please Enter RMA Number".
3) If reason is selected as SPLCPOY from drop down, then RMA Number/Copies column should be enabled and required field with a tip message as "Please Enter No. of Units".
4) If reason is selected as OTHERS from drop down, then customer comments column should be enabled with some default value and its required and RMA number/Copies field will be disabled.
5) If "RETURN" value selected and some values entered into the RMA number/copies field, and after that if drop down value is being changed, then RMA number/Copies field value should be cleared out and it should show the new tip for SPLCOPY only.
 
Very first we have to add 4 transient attributes to the VO as below. one is for RMA number and other for customer comments enable/disable:one is for RMA number and other for customer comments required/non required
 
 


 
 
Now First we will see how the page will be created:
1) Recommended reason property should be set as below:
 
 
 
 
2) As we have to set a tip conditionally on the same field, first we will create flow layout. see the below property:
 
3) under flowlayout, again we will create stack layout.

4) under stack layout we will create textinput item for RMA number/Copies field as below:


5) under stack layout, now we will create switcher which will be having two tip items. For switcher, we have to create different view attribute as well.
 
 
6) Now we will create two tips for RETURN and SPLCOPY case as below:

 
 
 
7) Now we have to write a logic in controller to get the reason value, after selecting the drop down value:
 
           if ("recReasonEvent".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM))) {
                       pageContext.writeDiagnostics(this, "recReasonEvent event start", 1);
                           String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
                  Serializable[] paramEnableCustCommentRma = { rowReference };
                  pageContext.writeDiagnostics(this, "before enableCustCommentRma method", 1);
                  am.invokeMethod("enableCustCommentRma",paramEnableCustCommentRma);
                  pageContext.writeDiagnostics(this, "after enableCustCommentRma method", 1);
           }
 
8) Now we have to write method in AM as below:
 
       public void enableCustCommentRma(String rowReference)
       {
           Row currentRow = findRowByRef(rowReference);
           String strRecommMeaning = (String)currentRow.getAttribute("Recomreason");
          getOADBTransaction().writeDiagnostics(this,"enableCustCommentRma :strRecommMeaning=" + strRecommMeaning, 1);
                           if (!(("").equals(strRecommMeaning) &&
                                 strRecommMeaning == null)) {
                               if (("OTHER").equals(strRecommMeaning)) {
                                   currentRow.setAttribute("IsCustCommentsDisabled", false);
                                   currentRow.setAttribute("IsRmaSplCopiesDisabled", true);
                                   currentRow.setAttribute("RmaSplCopies", null);
                                   currentRow.setAttribute("CustComments", "Explain why you need more than the Recommended Quantity of the item(s) highlighted below. There is 230 character limit");
                                   currentRow.setAttribute("IsRmaNumberRequired", "no");
                                   currentRow.setAttribute("IsCustomerCmtRequired", "yes");
                               }
                               else if (("RETURN").equals(strRecommMeaning) || ("SPLCOPY").equals(strRecommMeaning)) {
                                   currentRow.setAttribute("IsCustCommentsDisabled", true);
                                   currentRow.setAttribute("IsRmaSplCopiesDisabled", false);
                                   currentRow.setAttribute("IsRmaNumberRequired", "yes");
                                   currentRow.setAttribute("IsCustomerCmtRequired", "no");
                                   currentRow.setAttribute("RmaSplCopies", null);
                                   currentRow.setAttribute("CustComments",null);
                                   if(("RETURN").equals(strRecommMeaning))
                                   {
                                   currentRow.setAttribute("RmaSplTip", "rmaTip");
                                   }
                                   else
                                   {
                                       currentRow.setAttribute("RmaSplTip", "splTip");
                                   }
                               }
                               else if (("TONER").equals(strRecommMeaning)) {
                                   currentRow.setAttribute("IsCustCommentsDisabled", true);
                                   currentRow.setAttribute("IsRmaSplCopiesDisabled", true);
                                   currentRow.setAttribute("RmaSplCopies", null);
                                   currentRow.setAttribute("CustComments",null);
                                   currentRow.setAttribute("IsRmaNumberRequired", "no");
                                   currentRow.setAttribute("IsCustomerCmtRequired", "no");
                               }
                           }
       }
9) Now we will deploy all these objects on server, and bounce the server then test the scenarios:
 
first we select the different reasons for each line and see.
 
 

1 comment:

  1. Sands Casino | SA's Premier Entertainment | Play online at
    Play online at Sands Casino, SA's Premier Entertainment 샌즈 카지노 가입 쿠폰 | Play online at Sands Casino and get $20 free chip. Play Slots, Blackjack, Roulette and so much more.

    ReplyDelete