Sunday 14 December 2014

Override the custom hint message of af:inputDate

This blog we will see how to override the custom message of af:inputdate component.

Generally when user will click inside the af:inputDate component then the default hint message will display like the below screen.


Add the below code for override the default message.
<af:inputDate label="Label 1" id="id1">
      <af:convertDateTime hintDate="Add custom message" type="date"/>
</af:inputDate>
Now you run your page and the screen will looks like the below


Thanks...

Disable af:inputDate Default Message

This blog we will see how to hide the default message of af:inputdate component.
Generally when user will click inside the af:inputDate component then the default hint message will display like the below screen.

Now we will how we will hide this default message. Add the below java script inside the fragment.
<af:resource type="javascript">
    function hideDefaultMsg(event){
        var src = event.getSource();
        src.getPeer().ShouldShowHint =function(){
            return false;   
        }
    }
</af:resource>

After that you can add the af:clientListener inside the af:inputDate component like the below code
<af:inputDate label="Label 1" id="id1" >
    <af:clientListener method="hideDefaultMsg" type="focus"/>
</af:inputDate>
Now you run your page and the default message will not display like the below screen

Thanks...

Sunday 7 December 2014

Use of PanelCollection in Oracle ADF

This blog we will see use of af:panelcollection in Oracle ADF. 
This example table is surrounded with a panel collection component like the below screen.
Now run your page and page will looks like the below screen.
On runtime, af:panelCollection will be rendered with View menu item and other features. User can add or remove the columns from the table at run time.
User can sort the columns, click on View-->Sort-->Advanced

You can select the column name and sorting order like the below screen

User can rearrange the columns, click on View-->Reorder Columns… then the below screen will display and can arrange the columns.
Thanks..

Sunday 30 November 2014

Logout Implement in Oracle ADF

The below code is required for logout in ADF applications.
public String logOut()  throws IOException{
        HttpSession session = null;
          FacesContext fctx = FacesContext.getCurrentInstance();
          ExternalContext ectx = fctx.getExternalContext();
          session = (HttpSession)ectx.getSession(false);
          HttpServletResponse response = (HttpServletResponse)ectx.getResponse();                      String currentPage = "faces/login.jspx";
          String url = ectx.getRequestContextPath()+"/adfAuthentication?logout=true&end_url=" + currentPage;
         try {
             response.sendRedirect(url);
              session.invalidate();
         } catch (Exception ex) {
             ex.printStackTrace();
          }
          fctx.responseComplete(); 
          return null;
      }

Thanks...

Pagination in ADF

We Need to set the ScrollPolicy attribute to Page and autoHeightRow=”0”.
And if you want to display 5 rows in a page then set the RangeSize = 5 in iterator.



The screen will looks like

Thanks...

Monday 24 November 2014

Default editor of page to source code in Jdeveloper


Sometime Jdeveloper will be slow and it will take long time to open the files (ex –jspx, jsff etc) into design mode. If you want to open a jspx/jsff page directly into soure tab then you can follow the below steps.

Go to Tool > Preference > File Types and open default editor

 Thanks...

Sunday 23 November 2014

Print Functionality in Oracle ADF

To implement print functionality using Oracle ADF, we need to follow the below steps.
Approach -1:
Step-1:- Add <af:showPrintablePageBehavior/> component inside the button.

<af:commandButton text="Print1" id="cb1" binding="#{backingBeanScope.backing_PrintPage.cb1}">

<af:showPrintablePageBehavior/>

</af:commandButton>

Step-2:- Add before phase method inside view tag. Code show looks like the below


Step-3:- Add the below code inside backing/managed bean.

public void beforePhaseMethod(PhaseEvent phaseEvent) {

        if (phaseEvent.getPhaseId() == PhaseId.RENDER_RESPONSE) {

            FacesContext fctx = FacesContext.getCurrentInstance();

            Map requestMap = fctx.getExternalContext().getRequestMap();

            Object showPrintableBehavior = requestMap.get("oracle.adfinternal.view.faces.el.PrintablePage");

            if (showPrintableBehavior != null) {

                if (Boolean.TRUE == showPrintableBehavior) {

                    ExtendedRenderKitService erks = null;

                    erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);

                    //invoke JavaScript from the server

                    erks.addScript(fctx, "window.print();");

                }

            }

        }

    }

NOTE:- if you don’t want to display some component in your print page then add
rendered="#{adfFacesContext.outputMode != 'printable'}" to that component.


Approach-2: Add the below Code on click of button 
public String printPage() {
        // Add event code here...
        FacesContext facesContext = FacesContext.getCurrentInstance();

        org.apache.myfaces.trinidad.render.ExtendedRenderKitService service =
                   org.apache.myfaces.trinidad.util.Service.getRenderKitService(facesContext,   ExtendedRenderKitService.class);

               service.addScript(facesContext, "window.print();");
        return null;
    }


In this approach-2 it will not open the new window with content but the same page the print window will open.

Thanks...