Friday, November 26, 2010

How to export commandLink in the table into excel

Hi Friends,
        Some of you may have this problem,The problem is While you are exporting collumn in the commandLink,in the excel sheet the commandLink collumn field will be empty.The reason is the export is only for components of type ValueHolder, which a command ink is not.
      So I solve this problem by using an output text inside the commandLink,and in the outputText field property I use the value property,but in the text property of the commandLink is empty.

sample coding,
   <af:commandLink actionListener="#{bindings.setCurrentRowWithKey.execute}"
          text=""  id="cl4" action="edit">
           <af:outputText value="#{row.DocumentName}" id="ot2"/>
    </af:commandLink>

Hi this will work in all versions of the JDeveloper,This is one of solution,I dont know whether  this is a correct solution or not.If any alternative solution,please post your comments             

Clearing Filter criteria in ADF Rich Table

Hi Friends,this is one of my use-case for removing the filter text in the table when clicking a command button.
I think you all like this scenario.

Logic is,
           ADF table filter uses SearchRegion binding, which genearly uses a All Queriable Attributes Criteria. It will apply the criteria on the View object. So we need to clear the criteria on the view object.

The Solution is,
        1.Bind a table in the Jspx to a managed bean,say summaryTable.
        2.In the Jspx page,use a commandButton and in its Action property call a method in the managed bean for eg: clearFilters()

        3.Type the following code in the method,
  public String clearFilters(){
      if (summaryTable != null){
      FilterableQueryDescriptor queryDescriptor =
                                        (FilterableQueryDescriptor)summaryTable.getFilterModel();
      if (queryDescriptor != null && queryDescriptor.getFilterCriteria() != null){
      queryDescriptor.getFilterCriteria().clear();
      summaryTable.queueEvent(new QueryEvent(summaryTable,queryDescriptor));
      }
      else{
          String message = "Have some problem in Clearing Filters. please try later";
          FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message));
      }
      }
      return null;
  }


Now you run your application,type some filter text and click in the Button which will clear the filter text.
This example I tried in JDeveloper 11.1.1.2.0 . I hope it will work in all the versions of JDeveloper.If any problem post your comments or mail to felixandrew3@gmail.com

Thursday, November 25, 2010

How to invoke popup component programmatically in ADF

Hi All,
     Here is a sample solution for invoking the popup component from a method in the managed bean.

Solution.
     1.Create a button in the Jspx page.
     2.Create a popup componet inside the af|form (for eg:popup id=p1)   and bind the popup to a managed bean with name popup
     3.In the Action property of button,invoke a method in the managed bean( for eg.the method caller() )

In the backing bean code,

  public String caller(){
      showPopup(popup, null);
      return null;
 }
 public static void showPopup(RichPopup popup, UIComponent component) {
      FacesContext context = FacesContext.getCurrentInstance();
      String alignId = (component==null) ? null : component.getClientId(context);
      StringBuilder script = new StringBuilder();
      script.append("var popup = AdfPage.PAGE.findComponent('").append("p1").append("'); ")
              .append("if (!popup.isPopupVisible()) { ")
              .append("var hints = {}; ");
       if (alignId!=null) {
         script.append("hints[AdfRichPopup.HINT_ALIGN_ID] = '").append(alignId).append("'; ")
           .append("hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_AFTER_START; ");
       }
        script.append("popup.show(hints);}");
        ExtendedRenderKitService erks =
          Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
        erks.addScript(context, script.toString());
       }
    
Hi, Onething note this works in JDeveloper 11.1.1.2.0  But I dont know how about in other version.I hope it will work in all versions,

         If it dosn't works post your comment or mail to : felixandrew3@gmail.com . I will send you the sample code.