This discussion is archived
4 Replies Latest reply: Nov 8, 2012 5:44 PM by Subramanian Meyyappan RSS

Page Flow Problem

ck Explorer
Currently Being Moderated
Hello,

Im new for jdeveloper. Im ORAforms pl/sql programmer and no deep knowledge about java.

Im following the sample on https://blogs.oracle.com/shay/entry/for_some_reason_one_common.

Im trying this sample as forms manage security and before im diving deep to jdeveloper i need to study basic for this new IDE & framework{managed beans,biding..etc}.

And built it in scratch but i cannot make it navigate to another page after click the button heres the code i dont know how to explain much because im new maybe sharing the code would help.

My work not complete yet as when password not correct. just want first to navigate the welcome page when return value is GOOD.
Only need also when return value is BAD just display dialog or error message.

How to bind the manage bean?


VERSION : Studio Edition Version 11.1.2.3.0
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <af:document title="LogInPage.jspx" id="d1">
            <af:form id="f1">
                <af:panelStretchLayout topHeight="90px" startWidth="100px" id="psl1">
                    <f:facet name="top">
                        <af:panelStretchLayout id="psl4" startWidth="526px" endWidth="326px" topHeight="5px"
                                               bottomHeight="0px">
                            <f:facet name="bottom"/>
                            <f:facet name="center"/>
                            <f:facet name="start">
                                <af:image source="/images/njc_banner.PNG" id="i1"/>
                            </f:facet>
                            <f:facet name="end"/>
                            <f:facet name="top"/>
                        </af:panelStretchLayout>
                    </f:facet>
                    <f:facet name="center">
                        <!-- id="af_twocol_left_full_header_Stretched"   -->
                        <af:decorativeBox theme="dark" id="db2">
                            <f:facet name="center">
                                <af:panelStretchLayout startWidth="334px" id="psl2">
                                    <f:facet name="center">
                                        <af:decorativeBox theme="medium" id="db1">
                                            <f:facet name="center"/>
                                        </af:decorativeBox>
                                    </f:facet>
                                    <f:facet name="start">
                                        <af:decorativeBox id="db3" theme="medium" dimensionsFrom="parent">
                                            <f:facet name="center">
                                                <af:panelFormLayout id="pfl1" inlineStyle="height:365px;">
                                                    <f:facet name="footer">
                                                        <af:panelBorderLayout id="pbl1"
                                                                              inlineStyle="width:275px; height:27px;">
                                                            <f:facet name="start">
                                                                <af:group id="g1">
                                                                    <af:panelBorderLayout id="pbl2"
                                                                                          inlineStyle="height:173px; width:219px;">
                                                                        <f:facet name="right">
                                                                            <af:group id="g3">
                                                                                <af:spacer width="38" height="16"
                                                                                           id="s2"/>
                                                                                <af:group id="g2">
                                                                                    <af:commandButton text="Log In"
                                                                                                      id="cb1"
                                                                                                      action="login_action()"/>
                                                                                </af:group>
                                                                            </af:group>
                                                                        </f:facet>
                                                                    </af:panelBorderLayout>
                                                                </af:group>
                                                            </f:facet>
                                                        </af:panelBorderLayout>
                                                    </f:facet>
                                                    <af:spacer width="179" height="65" id="s1"/>
                                                    <af:inputText label="Username" id="it1" showRequired="true"
                                                                  requiredMessageDetail="Please Enter Your Username"
                                                                  autoSubmit="true" autoComplete="on" required="true"/>
                                                    <af:inputText label="Password" id="it2" secret="true"
                                                                  showRequired="true"
                                                                  requiredMessageDetail="Please Enter Your Password"
                                                                  autoSubmit="true" required="true"/>
                                                </af:panelFormLayout>
                                            </f:facet>
                                            <f:facet name="top"/>
                                        </af:decorativeBox>
                                    </f:facet>
                                </af:panelStretchLayout>
                            </f:facet>
                        </af:decorativeBox>
                    </f:facet>
                </af:panelStretchLayout>
            </af:form>
        </af:document>
    </f:view>
</jsp:root>
My Managed Bean
package njchis;


import oracle.adf.view.rich.component.rich.input.RichInputFile;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;
import java.sql.*;
import oracle.jdbc.OracleDriver;

public class GetUserName {
    private RichInputText it1;
    private RichInputText it2;
    private RichCommandButton cb1;

    public void setIt1(RichInputText it1) {
        this.it1 = it1;
    }

    public RichInputText getIt1() {
        return it1;
    }

    public void setIt2(RichInputText it2) {
        this.it2 = it2;
    }

    public RichInputText getIt2() {
        return it2;
    }

    public void setCb1(RichCommandButton cb1) {
        this.cb1 = cb1;
    }

    public RichCommandButton getCb1() {
        return cb1;
    }
   
    public String login_action() {
        // Add event code here...
        String user = this.getIt1().getValue().toString();
        String pass = this.getIt2().getValue().toString();
        Connection conn;

        try {
            conn = getConnection();
            Statement stmt = conn.createStatement();
            ResultSet rset = stmt.executeQuery ("SELECT 'x' FROM itdept.OFFICE_USERS where OFFICE_EMP_NO = '"+user+"' and OFFICE_PASS = '"+pass+"'");
            if (rset.next())  {
                conn.close();
                   return "good";                       
            }
            conn.close();
           
        } catch (SQLException e) {
            System.out.println(e);
        }
        return "bad";

    }

    public static Connection getConnection() throws SQLException {
        String username = "itdept";
        String password = "itdept";
        String thinConn = "jdbc:oracle:thin:@0.0.0.0:1521:XE";
        DriverManager.registerDriver(new OracleDriver());
        Connection conn =
            DriverManager.getConnection(thinConn, username, password);
        conn.setAutoCommit(false);
        return conn;
    }
   
}
PAGE FLOWS
<?xml version="1.0" encoding="windows-1252"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee">
  <application>
    <default-render-kit-id>oracle.adf.rich</default-render-kit-id>
  </application>
  <navigation-rule>
    <from-view-id>/LogInPage.jspx</from-view-id>
    <navigation-case>
      <from-outcome>good</from-outcome>
      <to-view-id>/Welcome.jspx</to-view-id>
    </navigation-case>
  </navigation-rule>
  <managed-bean>
    <managed-bean-name>GetUserName</managed-bean-name>
    <managed-bean-class>njchis.GetUserName</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
  </managed-bean>
</faces-config>
Edited by: ck on Nov 8, 2012 1:31 AM
  • 1. Re: Page Flow Problem
    ck Explorer
    Currently Being Moderated
    bumpp..
  • 2. Re: Page Flow Problem
    codigoadf Oracle ACE
    Currently Being Moderated
    in your code replace return "bad" String for message

            //return "bad";
            FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Your message text");
            FacesContext.getCurrentInstance().addMessage(null, msg);
    note: this is a JSF example no ADF example.
  • 3. Re: Page Flow Problem
    ck Explorer
    Currently Being Moderated
    hello,

    thank you for your reply.

    i will try your solution about the message but how about the navigation page to Welcome.jpfx when it returns GOOD?

    I will try first this simple thing before im going to deep on adf. I think adf is MVC thing.Need more study first but before that i need to familiar with all LAYOUT components and the IDE itself.

    thank you.

    Edited by: ck on Nov 8, 2012 9:56 AM
  • 4. Re: Page Flow Problem
    Subramanian Meyyappan Expert
    Currently Being Moderated
    this will help you.
    http://kohlivikram.blogspot.in/2008/10/how-to-create-simple-login-page-in-adf.html

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points