Wednesday, 24 October 2012

Checkbox validation in OAF using VO attribute.

I got a requirement for customization of a page where I need to create a check box. I need to do a Partial page Rendering using the Check box. That is, to enable and disable an LOV bean according to the event triggered in the check box.
I found that the Check box was already available in the seeded page and was not rendered. So I Personalized it to make it rendered.
I wrote the following code to do that Assignment.

PR
{
       
         OAMessageLovInputBean locationBean = (OAMessageLovInputBean)webBean.findIndexedChildRecursive("LocationCodeLov");
                
         OAMessageCheckBoxBean cbbean = (OAMessageCheckBoxBean)webBean.findChildRecursive("WorkAtHome");
         oracle.cabo.ui.action.FireAction FireActionA = new oracle.cabo.ui.action.FireAction();
         FireActionA.setEvent("Event");
         FireActionA.setUnvalidated(true);
         cbbean.setPrimaryClientAction(FireActionA);
        
         OAApplicationModule am = pageContext.getApplicationModule(webBean);
         OAViewObject pVO = (OAViewObject)am.findViewObject("LocationVO");
         OARow poRow = (OARow)pVO.getCurrentRow();
         String WorkAtHome = (String)poRow.getAttribute("WorkAtHome");
    
              if("Y".equals(WorkAtHome))          
              {
                  locationBean.setReadOnly(true);
              }
              else
              {
                  locationBean.setReadOnly(false);
              }
     }

PFR
    {
       
              if("Event".equals(pageContext.getParameter(EVENT_PARAM)))
                {
                   
                    pageContext.setForwardURLToCurrentPage(null,
                                                            true,
                                                            OAWebBeanConstants.ADD_BREAD_CRUMB_NO,
                                                            OAWebBeanConstants.IGNORE_MESSAGES);
                }
     }
}
}


Note about Check box:
                When a check box is created without the checked and unchecked value, it will be defaulted with ‘on’ when checked and   ‘null’ when unchecked. But, when it stored to DB or we set the values while creating a check box will be usually stored as ‘Y’ for checked and ‘N’ for unchecked.

No comments:

Post a Comment