Jdeveloper Jsf Download File from Server Apache Myfaces (Open Source JSF Implementation) – Using the Tree2 Component with Jdeveloper 10.1.3

Jdeveloper Jsf Download File from Server Apache Myfaces (Open Source JSF Implementation) – Using the Tree2 Component with Jdeveloper 10.1.3

jdeveloper jsf download file from server Apache MyFaces (open source JSF implementation) – Using the Tree2 Component with JDeveloper 10.1.3. In the wake of my last post – Getting started with Java Server Faces (JSF) using Apache MyFaces – in JDeveloper 10.1.3EA – I will continue my explorations of MyFaces in this article. In particular, I will take a look at the Tree2 Component that is shipped with Apache MyFaces. I will make use of Oracle JDeveloper 10.1.3 EA as my IDE. For details on setting up Apache MyFaces with JDeveloper 10.1.3, see the post I just mentioned. To make things easier for me – and hopefully for some of you as well – I have created a starter-project, a JDeveloper 10.1.3 Application Workspace with MyFacesBase project that contains the files you need to get started with MyFaces. You can simply download this zipfile: MyFacesBase.zip, extract it on your PC and open the JWS file in JDeveloper 10.1.3. You still need to set up the project with proper library definitions – see the previous post for details. Starting from this MyFacesBase Project we will create a beautiful tree-based JSF application. Sort of. Steps to prepare. I will first gear the base environment to my specific Tree oriented project: Extract MyFacesBase.zip to a directory; let’s refer to that directory as MyFacesTree_HOME Change the string Base to Tree in the names of the subdirectories MyFacesTree_HOME\MyFacesBase and MyFacesTree_HOME\MyFacesBase\MyFacesBase Open JDeveloper 10.1.3 Load the file MyFacesBase.jws; this will open the MyFacesBase application workspace Rename the Application to MyFacesTree. Change the name of the MyFacesBaseProject to MyFacesTreeProject. If you do not already see the project, then add it to the Application Workspace by adding the fiule MyFacesBaseProject.jpr. Go to the Project Properties of the MyFacesTree project. Verify in the Libraries tab whether the libraries MyFaces and JSTL are set up correctly and added to the project. If necessary see the post mentioned above. Also check whether the JSP Tag Libraries MyFaces-Core, MyFaces-HTML and MyFaces-ext (or Tomahawk) have been added to the project. Verifying the preparations. Now is a good time to make sure that we can indeed create and run JSF applications in the JDeveloper 10.1.3 environment and project we just set up. Follow the these simple steps: From the Right Mouse Button Menu on the MyFacesTreeProject project, go to the New Gallery. Select the node Web Tier, JSF and select the option JSF JSP. Walk through the Wizard, accepting all default choices – or making refinements as you like. The wizard create a JSP with basic JSF layout – importing the required Tag Libraries and layout a <f:view> and a <f:form>. The JSP is opened in the editor. Type a few characters – just to have some output to look at in our browser. Note: at this point we have not made any changes to faces-config.xml or any other configuration file. From the RMB menu on the JSP, choose the option run. The “application” should now open in the browser, displaying your trivial output. If you have gotten this far, you are in good shape to start using the MyFaces Tree component. Developing with the MyFaces Tree2 Component. Apache MyFaces is a valuable open source project providing the base implementation of the JSF standard and extending it with a large set of advanced components, called Tomahawk. The set includes TabbedPane, RssReader, Advanced Table features, inputDate and Calendar, HtmlEditor, Pulldown Menu, and many others. To confuse matters, there is a Tree, a Tree2 and a Tree Table component. It seems that Tree2 effectively replaces Tree; Tree is labeled ‘sort of obsolete’. So I focus on Tree2 for now. Using the JSP JSF wizard from the New Gallery I create a new JSP called LibraryTree.jsp. From the Component Palette, we drag and drop the Tree2 component to the JSP. The page source looks like: There are a few things worth noting here. First of all, the tree2 components has child facets; there is a facet for each type of node that the tree will contain. Apparently our tree wil contain nodes of types foo-folder, author and book. We will see later how we specify the node type on the backing bean’s model data. Each facet describes how the node type must be displayed; various node-types can make use of different icons, styles, actions etc. Note how the Node Interface provides properties like childCount, nodeExpanded and nodeSelected. The value for the tree2 component is set to: value=”# ”. That suggests that there is a Managed Bean called LibraryTreeHandler that exposes a getTreeModel method that returns an object that has a method getTreeData(). This last method must return an object that implements the TreeNode interface – in package org.apache.myfaces.custom.tree2. So there we go: create the required objects. First the LibraryHandler class: This class is a used for the managed bean called LibraryTreeHandler and referenced by the value property of the tree2 component. See the faces- config.xml file: The LibraryHandler class relies on the LibraryTreeModel class. Its code is as follows: The application looks like this in the browser. We can expand and collapse nodes. Note that all tree manipulation is done server side: each node expansion requires browser-to-server communication for updating the treenodes. The Project with the application so far can be downloaded here: MyFacesTree_Stage1.zip. Make the LibraryTree application a little more interesting. We are now going to make the application a little more interesting. We will allow Author nodes to be selected and we will display the Biography of the currently selected author – marked in the tree with an asterisk – next to the tree. It is remarkable how simple it is to add these changes to the application. If we select an Author node in the tree, the tree is redrawn and an asterisk is placed in front of that node – in the screenshot the selected node is for Orson Scott Card. At the same time, when the page is refreshed, the Results of the currently selected author are updated with the biography for the currently selected author. The changes I had to make to realize this functionality are in three location: 1. First the JSP LibraryTree.jsp. I have added the asterisk for the currently selected Author node: You can see how simple it is: the asterisk is only rendered if the current node in the tree is selected. To make the author node selectable, we add a commandLink: When the node is clicked on, the processAction method in the LibraryTreeHandler bean is invoked; this method needs to have a return type of void and accept a single ActionEvent input parameter. The next change is displaying the biography for the current author: I used a panelGroup for the rendered property: the entire panelGroup is only displayed if there is indeed a Biography available. Note that the bio is read from the authorBio property in the LibraryTreeHandler bean that is managed based on the LibraryHandler class. We will see that class in a moment. I finally made use of a panelGrid to display the tree and the bio next to each other. A panelGrid element in HTML is typically rendered as table. Okay, it is not pretty but it will do the trick. 2. The LibraryHandler class. This class now suddenly needs to provide an authorBio property and it has to absorb the processAction event. You can see that we make use of a new class, the ExtendedTreeNode. So we also need to create that class: 3. The new ExtendedTreeNode class. In order to have the new biography property for our Authors, we introduce this class: In class LibraryTreeModel we use this class to populate the nodes of our tree. The nodes we create for Authors are of the new ExtendedTreeNode type that include the biography. So we modify the LibraryTreeModel.java to: This is all it takes to create a dynamic tree, driven from a backend data model, including the select node action that updates the current biography. In a next article I will actually use the EJB 3.0 Persistence functionality out of container (the GlassFish implementation) for providing the backend data model. I will try to make the nodes updateable as well. File save dialog in jsf [duplicate] I am trying to export the result set of the DB in a excel format. And I am developing a web application using JSF. So what i need is that when the user clicks on the EXPORT button in my page , then a file save dialog has to open for the user to choose the directory path and the name for the file. And when the save is clicked in the file dialog then i need to write the whole result set to the excel sheet with the mentioned name and path as per users input. But i couldnt find the file save dialog and how to use the same with JSF. And I am using jdeveloper for the development . hassan4abdalla. This Site Sharing The knowledge That I Have And What I Found On Internet Community. Recent Posts. أھﻢ ١٠ اﺧﺘﺮاﻋﺎت ﻣﻦ Minimum System Requirements To Run Windows 10 How to Activate Super Administrator Account in Windows 7/8/8.1/10 .ﺻﻨﻊ اﻟﻤﺴﻠﻤﯿﻦ ﺗﺼﻤﯿﻢ ﺗﻄﺒﯿﻘﺎت أﻧﺪروﯾﺪ ﺑﺪون ﻟﻐﺔ ﺑﺮﻣﺠﺔ ﷴ ﻣﻨﺪور اﻟﻤﮭﺪي Recent Comments. hassan4abdalla on Java IDEs – NetBeans vs Eclips… hassan4abdalla on Java IDEs – NetBeans vs Eclips… Thiyagu on Java IDEs – NetBeans vs Eclips… Sven on Java IDEs – NetBeans vs Eclips… Archives.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us