JSF Sample Web Applications - Petstore

Hi,
I have just started on JSF after working on struts for quite some time.Is the any web application with JSf and facelets demonstrating features like session handling,best practices like use of Business delegates etc just like the petstore sample application?
Regards
Raj

Take a look at this site
www.javaworld.com/javaworld/jw-07-2004/jw-0719-jsf.html

Similar Messages

  • MySQL & JSF driven Web Application

    I have the whole database, written in SQLyog. I already have a huge GUI application that works with this database.
    I didn't use Hibernate for object mapping, all the SQL statements I wrote manualy.
    I want to make a small web aplication that will read the same data from the database and display it in the
    web browser, possibly, using JSF, my faces ect.
    Anyone have any clue where is a good place to begin with it?
    Thank you

    For future JSF related questions, here is the JSF forum: [http://forums.sun.com/forum.jspa?forumID=427].
    If you're new to JSF, I recommend to read the JSF specification first, it explains why JSF is there and what it all can. Then read some documentation/tutorials/books about it.
    JSF specification document (pick the first one): [http://jcp.org/aboutJava/communityprocess/final/jsr252/index.html]
    JSF API document (the javadocs): [http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/overview-summary.html]
    JSF TLD document (the tagdocs): [http://java.sun.com/javaee/javaserverfaces/1.2/docs/tlddocs/index.html]
    JSF tutorial in Java EE tutorial part II chapter 10: [http://java.sun.com/javaee/5/docs/tutorial/doc/bnaph.html]
    There are also another sites which covers good JSF tutorials/examples/articles:
    Coreservlets JSF tutorials (check the Sun-RI examples): [http://www.coreservlets.com/JSF-Tutorial/]
    JSFTutorials.net (overview of all links/articles): [http://jsftutorials.net/]
    The Balusc Code (lot of JSF related articles, check right column): [http://balusc.blogspot.com/]
    A recommendable JSF book:
    JSF The Complete Reference: [http://www.amazon.com/JavaServer-Faces-Complete-Reference/dp/0072262400]

  • JSF Web Applications

    Hi,
    I have just started on JSF after working on struts for quite some time.Is the any web application with JSf and facelets demonstrating features like session handling,best practices like use of Business delegates etc just like the petstore sample application?
    Regards
    Raj

    Hi,
    I have just started on JSF after working on struts for quite some time.Is the any web application with JSf and facelets demonstrating features like session handling,best practices like use of Business delegates etc just like the petstore sample application?
    Regards
    Raj

  • Problem in JSF with Swing in a web application

    hi
    i am using jsf for my online projects.my problem is that when i use Swing concept ,the server is closed automatically when i click the swing dialog option 'OK', how can i protect server being closed automatically when user click the the options of Swing dialog box.it is so tedious because my application is going to integrate
    with online server?
    my swing java file is
    * FileExistsDialog.java
    package com.obs.ftw.util.alert;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.Rectangle2D;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.plaf.metal.MetalLookAndFeel;
    * FileExistsDialog: A JOptionPane-like dialog that displays the message
    * that a file exists.
    public class FileExistsDialog extends JDialog {
    * The component that gets the focus when the window is first opened
    private Component initialFocusOwner = null;
    * Command string for replace action (e.g., a button).
    * This string is never presented to the user and should
    * not be internationalized.
    private String CMD_REPLACE = "OK"/*NOI18N*/;
    * Command string for a cancel action (e.g., a button).
    * This string is never presented to the user and should
    * not be internationalized.
    private String CMD_CANCEL = "CANCEL"/*NOI18N*/;
    // Components we need to access after initialization
    private JButton replaceButton = null;
    private JButton cancelButton = null;
    public FileExistsDialog(){
         System.out.println("INSIDE THE FILE EXIST DIALOG");
         JFrame frame = new JFrame() {
         public Dimension getPreferredSize() {
         return new Dimension(200,100);
         frame.setTitle("Debugging frame");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.pack();
         frame.setVisible(false);
    FileExistsDialog dialog = new FileExistsDialog(frame, true);
         dialog.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent event) {
         System.exit(0);
         public void windowClosed(WindowEvent event) {
         System.exit(0);
         dialog.pack();
         dialog.setVisible(true);
    * Creates a new FileExistsDialog
    * @param parent parent frame
    * @param modal modal flag
    public FileExistsDialog(Frame parent,boolean modal) {
    super(parent, modal);
         //initResources();
         System.out.println("INSIDE THE FILE EXIST DIALOG CONSTRUCTOR");
    initComponents();
    pack();
    * Determines the locale, loads resources
    /* public void initResources() {
         Locale locale = Locale.getDefault();
    resources = ResourceBundle.getBundle(
              "samples.resources.bundles.FileExistsDialogResources", locale);
    imagePath = resources.getString("images.path");
    }*/ // initResources()
    * Sets all of the buttons to be the same size. This is done
    * dynamically after the buttons are created, so that the layout
    * automatically adjusts to the locale-specific strings.
    private void equalizeButtonSizes() {
         System.out.println("INSIDE THE equalizeButtonSizes()");
    String[] labels = new String[] {
    replaceButton.getText(),
         cancelButton.getText()
         // Get the largest width and height
         Dimension maxSize= new Dimension(0,0);
         Rectangle2D textBounds = null;
         Dimension textSize = null;
    FontMetrics metrics =
              replaceButton.getFontMetrics(replaceButton.getFont());
         Graphics g = getGraphics();
         for (int i = 0; i < labels.length; ++i) {
         textBounds = metrics.getStringBounds(labels, g);
         maxSize.width =
         Math.max(maxSize.width, (int)textBounds.getWidth());
         maxSize.height =
         Math.max(maxSize.height, (int)textBounds.getHeight());
    Insets insets =
         replaceButton.getBorder().getBorderInsets(replaceButton);
    maxSize.width += insets.left + insets.right;
    maxSize.height += insets.top + insets.bottom;
    // reset preferred and maximum size since BoxLayout takes both
         // into account
    replaceButton.setPreferredSize((Dimension)maxSize.clone());
    cancelButton.setPreferredSize((Dimension)maxSize.clone());
    replaceButton.setMaximumSize((Dimension)maxSize.clone());
    cancelButton.setMaximumSize((Dimension)maxSize.clone());
    } // equalizeButtonSizes()
    * This method is called from within the constructor to
    * initialize the dialog.
    private void initComponents() {
         System.out.println("INSIDE THE initComponents()");
         // Configure the window, itself
    Container contents = getContentPane();
    contents.setLayout(new GridBagLayout ());
    GridBagConstraints constraints = null;
    setTitle("Waring");
         // accessibility - all applets, frames, and dialogs should
         // have descriptions
         this.getAccessibleContext().setAccessibleDescription("Descriptions");
         addWindowListener(new WindowAdapter() {
         public void windowOpened(WindowEvent event) {
              // For some reason the window opens with no focus owner,
              // so we need to force the issue
         if (initialFocusOwner != null) {
              initialFocusOwner.requestFocus();
              // Only do this the 1st time the window is opened
              initialFocusOwner = null;
         public void windowClosing(WindowEvent event) {
         System.out.println("INSIDE THE windowClosing");     
         // Treat it like a cancel
              windowAction(CMD_CANCEL);
         // image
    JLabel imageLabel = new JLabel();
    imageLabel.setIcon(
    new ImageIcon("/images/degraded_large.gif"));
    // accessibility - set name so that low vision users get a description
    imageLabel.getAccessibleContext().setAccessibleName("OK");
    constraints = new GridBagConstraints ();
    constraints.gridheight = 2;
    constraints.insets = new Insets(12, 33, 0, 0);
    constraints.anchor = GridBagConstraints.NORTHEAST;
    contents.add(imageLabel, constraints);
    // header
    JLabel headerLabel = new JLabel ();
    headerLabel.setText("SAMPLE");
    headerLabel.setForeground(
         new Color(MetalLookAndFeel.getBlack().getRGB()));
    constraints = new GridBagConstraints ();
    constraints.insets = new Insets(12, 12, 0, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(headerLabel, constraints);
         // Actual text of the message
         JTextArea contentTextArea = new JTextArea();
    contentTextArea.setEditable(false);
    contentTextArea.setText("SAMPLE");
    contentTextArea.setBackground(
              new Color(MetalLookAndFeel.getControl().getRGB()));
    // accessibility -- every component that can have the
         // keyboard focus must have a name. This text area has no
         // label, so the name must be set explicitly (if it had a
         // label, the name would be pulled from the label).
    contentTextArea.getAccessibleContext().setAccessibleName(
              "CONTENTNAME");
    constraints = new GridBagConstraints ();
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.insets = new Insets(0, 12, 0, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(contentTextArea, constraints);
         // Buttons
         JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout (new BoxLayout(buttonPanel, 0));
         replaceButton = new JButton();
         replaceButton.setActionCommand(CMD_REPLACE);
    replaceButton.setText("OK");
    replaceButton.setToolTipText("TO OK");
         replaceButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent event) {
         windowAction(event);
    buttonPanel.add(replaceButton);
    // spacing
    buttonPanel.add(Box.createRigidArea(new Dimension(5,0)));
         cancelButton = new JButton();
         cancelButton.setActionCommand(CMD_CANCEL);
    cancelButton.setText("CANCEL");
    cancelButton.setNextFocusableComponent(replaceButton);
         cancelButton.setToolTipText("TO CANCEL");
         cancelButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent event) {
         windowAction(event);
    buttonPanel.add(cancelButton);
    constraints = new GridBagConstraints ();
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.insets = new Insets(12, 12, 11, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(buttonPanel, constraints);
         // Equalize the sizes of all the buttons
         equalizeButtonSizes();
         // For some reason, the dialog appears with no input focus.
         // We added a window listener above to force the issue
         initialFocusOwner = replaceButton;
    } // initComponents()
    * The user has selected an option. Here we close and dispose the dialog.
    * If actionCommand is an ActionEvent, getCommandString() is called,
    * otherwise toString() is used to get the action command.
    * @param actionCommand may be null
    private void windowAction(Object actionCommand) {
         System.out.println("INSIDE THE WINDOW ACTION");
         String cmd = null;
    if (actionCommand != null) {
         if (actionCommand instanceof ActionEvent) {
         cmd = ((ActionEvent)actionCommand).getActionCommand();
         } else {
         cmd = actionCommand.toString();
         if (cmd == null) {
         // do nothing
         } else if (cmd.equals(CMD_REPLACE)) {
         System.out.println("your replace code here...");
         } else if (cmd.equals(CMD_CANCEL)) {
         System.out.println("your cancel code here...");
         setVisible(false);
         dispose();
    } // windowAction()
    * This main() is provided for debugging purposes, to display a
    * sample dialog.
    // main()
    } // class FileExistsDialog
    and calling java function is
    public String fileDialog(){
         return "Success";
    public void processFile(ActionEvent event){
         System.out.println("INSIDE THE FILE DIALOG");
         FileExistsDialog file     = new FileExistsDialog();
         System.out.println("SUCCESS");
    called from
         <h:commandButton action="#{userLogin.fileDialog}" actionListener="#{userLogin.processFile}"></h:commandButton>
    pls help me as soon
    advance thanks
    rgds
    oasisdeserts

    Swing is GUI library for use in desktop applications.
    JSF is a web application framework which runs on an application server and is accessed by clients via web browsers.
    To fully understand what you have done, try accessing your application from a different machine than the server.
    To answer your question, don't invoke System.exit() if you would like the process to continue. But that is the least of your problems.

  • Sample questions on SAP NetWeaver-Web Application Develpment certification

    hello frnds,
    can i find any sample questions on
    <i><b>SAP NetWeaver-Web Application Develpment - JAVA</b></i> certification?
    what are the books/material should i follow for the same ?
    Thank you,
    Regards,
    Shobhan

    hi Sobhan
    Please try on
    braincert.com
    Farook

  • For a new web application project - Struts OR JSF ?

    Hi ,
    We are starting a new web application project and want to decide whetehr to us Struts or JSF ?
    Currently, mots of the other development teams are using Struts .
    We need to know pros and cons of each to decide one way or the other.
    Any help is appreciated .
    Thanks

    Those are the articles and presentation about this topic:
    http://homepage1.nifty.com/algafield/barcia.html
    http://www.jroller.com/comments/dgeary/Weblog/top_ten_reasons_to_prefer
    http://websphere.sys-con.com/read/46516.htm
    http://www.pjug.org/JavaServerFaces.pdf
    Sergey : http://jsfTutorials.net

  • Does any body have any design patterns of JSF Web Application Developping?

    Can any one answer me some questions?
    #1.I am an amatuar of people who develop Web Application.For some reason,We choose the JSF to develop our item.through some introduction,I know the UI component of JSF is resided in Server side,is it right?but I am a little confused that:if there are many users who are exploring our jsf website.(to simplify my question,image I had just one web page and just one button)How many UI components(buttons) will be there?How it(they?) works?
    #2.Does any body have the success experience (for example design pattern)to develop web applications?if We just concern about the Add,Delete,Modify,Query operations of some data.
    I just do my job according to my feeling.
    I will give every page a pagebean(backing bean),and I am not sure how to combine the business data with the pagebean.some one suggested that I should use delegate pattern to separate my business log and page logic.But I am still confused by following things:
    #2.1 does JSF have the same ability to help us construct the model dialog just like swing to
    help us control the operation flow?
    #2.2 If there is not,Does the following way work?I put every tabledata's property as corresponed component.if user choosed the row in the table,My Listener will syncronize the row data to the components.But
    #2.2.1 if JSF has the components according to the web users' number,how can My Listener tell which component should be update?Should I maintain the map?
    #2.2.2 If the problem I imaged above is false,Does any body can tell me how to custom      the ListDataModel,so I can use it like Swing?because now I can just use some view data to insert into ListDataModel,but after some selection operation,my business object must be find according to the selected data,it is not an interesting job!
         I am waiting for your advice!

    Ok I'll try to explain Step by step please correct me if I make any mistake because I have not played much with shared variables.
    To create a shared variable to an RT target go to the target if tou have already otherwise add an RT target by right clicking the Project>>Add targets and Devices
    Then in the target Right clikc and select the variable as shown below.
    Then once the Shared variable settings window opens Enter a variable name and then Select the type "Network Published"
    In the right side you can select the data type for the shared variable and even you can choose your custome controls.
    After selecting the data type go for the Network and select buffering if required else leave it if you are planning to use the variable just for display purpose.
    Then you can enable the RT FIFO if required (Not able to explain how it works and why it is used).
    Then after completing the Shared variable setup you can access the variable in the VI in both the Host and the RT.
    You can bind the variable to a control so that if any data from the RT is coming you can read the data from that control.
    Once you have placed your shared variable in the BD you can change the access typr to read or write depending on your need.
    This might not explain the complete shared variable concept but I believe that this would defenelty give you a kick off to start using the shared variable. Please correct or add more comments if anybody know better.
    Good luck.
    The best solution is the one you find it by yourself

  • Creating a JSF Web application from scratch.

    hi,
    i have created a JSF web application, but not from scratch i had to use a jsf example included in the final specification of the JSF download, as a template to create my own application, by deleting and editing the example files with my own.
    i tried to do it from scratch including all the settings, parameters and files that should be in place, but i sill get an error when starting the app in tomcat.
    Unfortunately i dont have the error listing anymore since i have got around the problem through alternate path. however i do remember that it came with cannot find FacesServlet, or something to do with the FacesServlet.
    if anyone could shed some light on this it would be really great because it so frustrating.
    many thanks.
    dharam

    cannot find FacesServlet, or something to do with the FacesServlet.It might appear not because you have a wrong project structure, but because you point to the entry jsp file directly without using the servlet mapping in your URL. Check this first.
    Sergey : jsfTutorials.net

  • How to display BLOB image column with WEB application, JSF, ADF BC

    I looking for a way to display the content from a blob column on a WEB application, JSF, ADF BC
    The blob column contains a JPEG image.
    About the application
    The model contains a viewobject where the blob column attribute (photoimg) type is of type : BlobDomain
    Now I have to create the view to display the content of photoimg inside a JSF-JSP page.
    Any advice ?

    Search is your friend
    How to display the content of a BLOB column in a ADF/BC pages ?
    John

  • Call a JSF application from a Standar Web application (JSP)

    Hi all,
    We have 2 aplication, one is JSF and the other one is standar web jsp.
    We want to invoke from the standard web application to the JSF application and pass param from the jsp to the *.jsf page.
    how can I do that?
    Thanks.

    You can open a jsf page from any other application.
    <form action="http://hostip:port/app/MyPage.jsf?key1=value1&key1=value1">
    as we do in any other jsp page.
    Now in JSF application, in MyPage.jsf write a scriptlet to get the parameters and from there you can use these params.
    You can get a managed Bean reference in your jsp page. Here is the code for that.(ResultsInExcelBean is my managed bean.)
    FacesContext fc = FacesContext.getCurrentInstance();
         ResultsInExcelBean resultsInExcelBean = (ResultsInExcelBean)fc.getApplication().createValueBinding("#{ResultsInExcelBean}").getValue(fc);     
    Hope this helps you.
    Sravan

  • Jsf web application has to be restarted everytime a broken pipe exception

    Hi,
    My jsf web application using tomcat is experiencing a sql exception "java.sql.SQLException: System or internal error java.net.SocketException: Broken pipe" when it tries to connect to database.
    Everytime this exception happens I have to restart the application and the application runs fine then.
    Is there a way to handle this exception that we don't have to restart the application.
    -kap

    It depends....
    How do you have (where) the connection, how you obtain them, etc?

  • Access an Application Module Client Interface in a JSF Web Application

    How to Access an Application Module Client Interface in a JSF Web Application
    I use this code but class ValueBinding is deprecated in JDeveloper11g
    FacesContext fc=FacesContext.getCurrentInstance();
    ValueBinding vb=fc.getApplication().createValueBinding("#{data}");
    BindingContext bc=(BindingContext)vb.getValue(fc);
    DCDataControl dc=bc.findDataControl("SRServiceDataControl");
    ApplicationModule am=(ApplicationModule)dc.getDataProvider();

    user581394,
    JDeveloper 11 and the introduction of ADF Faces RC introduces a new dependency, which is JSF 1.2. The createValueBinding on the FacesContext object is deprecated in JSF 1.2. To resolve an expression in JSF 1.2 use the following method or something similar.
        public static Object resolveExpression(String expression) {
            FacesContext facesContext = getFacesContext();
            Application app = facesContext.getApplication();
            ExpressionFactory elFactory = app.getExpressionFactory();
            ELContext elContext = facesContext.getELContext();
            ValueExpression valueExp =
                elFactory.createValueExpression(elContext, expression,
                                                Object.class);
            return valueExp.getValue(elContext);
        }--RiC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Merging Two JSF, ADF BC Web Applications into One web application

    What would be the best way to take two JSF, ADF BC web applications written by two developers and merge them into one web application. Any place to start would be greatly appreciated. I'm using Oracle JDeveloper - 11.1.1.4.0
    Edited by: Sunanda on Jul 26, 2011 4:13 AM

    Take a look at this thread:
    Merging Two JSF, ADF BC Web Applications into One...
    Although the thread is old, but it provides about the types of contents you would need to take into consideration while merging.
    With the knowledge from the above thread, you could use refactor option in the JDeveloper menu to move the contents from one project to another.
    Thanks,
    Navaneeth

  • Compiling simple web application in samples

    I recently downloaded the J2EE SDK and opened the indexSamplesDomain.html file under the samples directory. Clicked the simple web application link and proceeded to follow instructions to build the application. In this very first example I received an error stating that asant tool could not find the common-ant.xml file in the samples directory. Anyone have any idea the simplest example application has a bug in the build script????
    thanks

    Hi
    You should have a variable called FORMACTION_22_0 ,what you could try as well is to remove the forms autocorrelation from the script:
    In OpenScript: View -> OpenScript Preferences -> Correlation -> HTTP, click on the +* to open DOM Correlation, then double click on it and uncheck the action check box.
    Then you will need to re-correlate the script.
    Script -> Correlate Script
    That should remove all the form variables.
    Alex

  • Merging Two JSF, ADF BC Web Applications into One...

    My question is directly stated in the subject. What would be the best way to take two JSF, ADF BC web applications written by two developers and merge them into one web application. Any place to start would be greatly appreciated. Thank you.

    Steve I wanted to try this method out first. I ran into a problem. I get a "HTTP 404 Not Found" error in the browser. I'm running this from the embedded OC4J in JDev. Maybe I don't understand how the context roots are referenced by the OC4J as they relate to testing this on my local machine.
    Browser links when pages are run seperately:
    http://10.13.8.44:8989/DptApp-UserInterface-context-root/faces/DptApp.jspx
    http://10.13.8.44:8989/EmpApp-UserInterface-context-root/faces/EmpApp.jspx
    Page locations on my local machine:
    \JDEV32\jdev\mywork\DptApp\UserInterface\public_html\DptApp.jspx
    \JDEV32\jdev\mywork\EmpApp\UserInterface\public_html\EmpApp.jspx
    Code from the bean that I'm using to navigate from EmpApp to DptApp:
        public String rtnRedirect() throws IOException {
            FacesContext fc = FacesContext.getCurrentInstance();
            HttpServletResponse response = (HttpServletResponse)fc.getExternalContext().getResponse();
            response.sendRedirect("/DptApp/faces/DptApp.jspx");
            fc.responseComplete();
            return null;   
        }I altered my redirect to reflect what I was seeing on my local machine (response.sendRedirect("/DptApp-UserInterface-context-root/faces/DptApp.jspx")) and still got the error. I'm sure I'm referencing the location of the pages incorrectly, but I'm not sure where to look to fix this. Any suggestions would be greatly appreciated. Thanks.

Maybe you are looking for

  • Open instance in same window

    In 6.0.x. when a instance in the workspace inbox is clicked, it opens in a new window, but in 5.7 it opens on the same page, is there any way to make the inbox instance open in the same window (html page). Pardon me, I had put this query in the runti

  • Need to view concurrent request output(pdf file of XML report)from OAFpage

    Hi, I am submitting a concurrent request from OA page (on click of submit button). As of now, to view output of the request user has to open SRS form. Now the rquirement is to submit the request as well as to open the output file of the request in on

  • Workflow giving unknown error in production

    Hi Experts, I had workflow working fine in dev and qa . But its not working in production . I tried to execute the workflow directly through swdd. It is telling 'Workflow cannot be activated' after executing . When i tried to display the workflow log

  • Flash Player 11.3 Installer Keeps Loading and Trying To Install Itself - Cannot Get It To Stop!!

    Because of all of the problems that I have been experiencing with the Flash Player 11.3, I uninstalled it and downgraded to 11.1, which seems to be a more stable version.  I used the uninstaller as recommended by Firefox and then grabbed the 11.1 ver

  • Slection condition with Like

    Hi Gurus, I try to extrat from the table CSKS the cost element (KSTAR) only those starting by 8. I have written this code but I always receive a sy-subrc = 0. PARAMETERS srch_str TYPE cska-kstar. TYPES: BEGIN OF ty_cska,         kstar TYPE cska-kstar