Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label .jsff. Show all posts
Showing posts with label .jsff. Show all posts

Thursday 30 May 2013

Add Custom Flash Chat in Oracle ADF Application

In this tutorial i am going to show that how can you add a custom flash chat in your ADF application, and use it to chat with friends.
this is very much simple, as no code required to do this.
  • Go to http://www.everywherechat.com/ , this site provides free custom flash chat rooms, get html code of your custom chat from here
  • Create an html page using that code




  • <html>
    <body>
    <!-- Begin Everywherechat Room Code -->
        
          <br />
         <script src="http://www.everywherechat.com/e.php?defaultRoom=Lobby&roomList=true&fontSize=12&width=600&height=500&theme=night"></script> 
    
    <!-- End Everywherechat Room Code --> 
    </body>
    </html>
    

  • Now create a Fusion Web Application and create a page in it, call this HTML page in an inlineFrame (af:inlineFrame)

  • <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <af:panelGroupLayout id="pgl1">
        <af:inlineFrame id="if1" source="/chat.html" inlineStyle="height:700px;width:700px;"/>
      </af:panelGroupLayout>
    </jsp:root>
    

  • Now Run your application and see your flash chat room is ready - Happy Coding

    Download Sample Application-Sample ADF Application

Wednesday 15 May 2013

Beauty of ADF- Taskflow, Difference b/w Facelets and JSP XML fragments in bounded taskflow

Oracle ADF framework support modular architecture for enterprize application development. Multiple small module can be bound together to form a large module .
The greatest advantage of ADF controller over core JSF navigation model is that it splits a single bulky module to multiple reusable and interconnected modules known as Taskflows.

i am not going deeper in Taskflows as every ADF developer know about it ,so the important part is page fragment.
  • When  we create taskflow as bounded taskflow , and check it to create fragment in taskflow.
  • Now when we create pagefragment in bounded taskflow, there is 2 option for creating fragment




Create fragment as Facelets
Create fragment as JSP XML 

Page Fragment Type - Facelets or JSPX

Facelets- is default and official view handler for JSF pages, priviously JSP was used to view JSF pages but it didn't support all component so Facelets comes in picture under APACHE open source license. It supprts all UI component used by JSF (Java Server Faces).
Facelets was developed by Jacob Hookom in 2005.
If you create Facelets fragment in bounded taskflow, then taskflow must be dropped in a JSF page (parent page) not in .jspx (JSP XML ) page.
if you try to drop it into JSP XML page-


JSP XML- jspx is XML variant of JSP(Java Server Pages) to support XML document . JSP XML fragments are used in ADF inorder to support XML document and more powerful page validation techniques.
If you create jsp xml fragments in bounded taskflow, then taskflow must be dropped in a JSP XML(.jspx) page(parent page) not in JSF page.

Thursday 11 April 2013

Invoking Button Action Programmatically,Queuing ActionEvent

Sometimes we need to invoke any button's action in bean without pressing that button,
as you have to call button action on any component's value change Listener- So how to do this in ADF managed bean.
ADF provides facility to queue action one after another, means you can perform multiple action by queuing 

I am using bounded task flow with page fragments(.jsff)-

  • Create a button in page fragment and define ActionListener in managed bean
  • Now I have created a input text and its valueChangeListener in managed bean
  • I wish to call button' ActionListener in my input text valueChangeListener .




  • we can do this by writing this code snippet on valueChangeListener 

  • public void callAceVCE(ValueChangeEvent vce) {
    if (vce.getNewValue() != null) {
    //Code to call ActionEvent
    FacesContext facesContext = FacesContext.getCurrentInstance();
    UIViewRoot root = facesContext.getViewRoot();
    /**Pass cb1(buttonId) if page is not in taskflow, else if page is inside region then pass rgionid:buttonId*/
    RichCommandButton button = (RichCommandButton)root.findComponent("r1:cb1");
    ActionEvent actionEvent = new ActionEvent(button);
    actionEvent.queue();
    }
    }

  •  Now run your page and when you will change input text value - button actionListener will be called

Global Exception Handler for ADF Task Flow Method Calls

Exception Handler is the central point for handling unexpected Exceptions that are thrown during the Faces lifecycle.
ADF Task Flow provides this facility, using this you can handle all exception that raised in TaskFlow methods.
here i am using ADF bounded TaskFlow with page fragments(.jsff) .
Developers must use this facility to avoid unexpected exception inside taskflows.

This is very simple approach , you have to do nothing more but create a method in Task Flow and mark it as Exception Handler and write your code inside this method , that you want to show when any exception is caught in TaskFlow.

To implement this i have implemented this scenario-

  • Create a method that throw an Exception and add it to taskFlow, and on page call this method on button click

  • public void exception() {
    throw new JboException("Failded to load");
    }
Control Flow Case in Bounded taskFlow
  • When we click on button that call exception() method ,JboException is raised inside TaskFlow and look like this- Your page crashed

  • Now create a method that will behave as ExceptionHandeler  and add it to TaskFlow and mark as Exception Handeler (Symbol in Jdev toolbar for marking)

  • public void exceptioHandeler() {
    System.out.println("Inside Handeler");
    FacesMessage message = new FacesMessage("This is custom Message for Jbo Exception-Exception Handeler");
    message.setSeverity(FacesMessage.SEVERITY_WARN);
    FacesContext fc = FacesContext.getCurrentInstance();
    fc.addMessage(null, message);

    }

Drop a method as Exception Handler in Bounded Taskflow
  • Use this sign to mark method as Exception Handeler in bounded Task Flow




There is a red icon to mark method as exception handler

  • Now Run your page and click on button that call exception() method, your page never crash, as there is handler
Customised Message appears in case of any exception in taskflow
Find Sample application Download Sample ADF Application

Monday 15 October 2012

ADF Basics: .jspx and .jsff page in Oracle ADF


.jspx-


.jspx page is JSP/XML representation, it is standalone page means it can run without any supporting or base page.
Jdeveloper 11g Release1 supports .jspx page but  Release2 supports both jspx and Facelets


.jsff page-


.jsff (JSF fragments) page is fragment of JSF(Java Server Faces) page, sometimes pages become to much complex and large and it is not easy to edit those pages, in that case it should be devided in some fragments.
JSF page can be broken in some smaller page fragments to avoid difficulties in editing and maintaining
page fragments can't run independently, it requires a base of .jsf(JSF page) or .jspx (JSP/XML)
page.

Facelets-


Java Server pages(JSP) technology previously used as view declaration for Java Server Faces (JSF) but it doesn't support all the feature of JSF available in JDK1.6 (Java 6), Facelets is introduced under Apche license and default view declaration technology for Java Server Faces.
Facelets supports all the new features introduced in JSF technology, Facelets requires XML document to work
  • Facelets supports HTML and XHTML for designing
  • Fasetr execution than JSP
  • Supports Facelets tab library with JSF and JSTL tag lib

JSP and JSPX-


The main difference I know is that JSP supports HTML and JSPX is XML variant of JSP. .jspx supports more component than jsp page and also compatible with JSF page fragments.