Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

navigating to another page in a bean

Tony007May 19 2016 — edited May 23 2016

hi am in jdeveloper 11.1.1.9  I have a situation where I have to navigate to next page based on the condition how can I do that

this is what I have done so far

hi in my AppModuleTstImpl class the have this

    protected Object callStoredFunction(int sqlReturnType, String stmt, Object[] bindVars) {

            CallableStatement cst = null;

            try {

                //Creating sql statement

                cst = this.getDBTransaction().createCallableStatement("begin ? := " + stmt + ";end;", 0);

                //Register dataType for return value

                cst.registerOutParameter(1, sqlReturnType);

                //Pass input parameters value

                if (bindVars != null) {

                    //for (int z = 0; z < bindVars.length; z++) {

                    for (int z = 0; z < bindVars.length; z++){                                              

                        cst.setObject(z + 2, bindVars[z]);

                    }

                }

                cst.executeUpdate();

                //Finally get returned value

                return cst.getObject(1);

            } catch (SQLException e) {

                throw new JboException(e.getMessage());

            } finally {

                if (cst != null) {

                    try {

                        cst.close();

                    } catch (SQLException e) {

                        e.printStackTrace();

                    }

                }

            }

        }

public String getUsrStstus(String UsrId) {

            String UserSts = "No Status found";

            Object UsrStatus = callStoredFunction(Types.VARCHAR, "Cal.Usr_status(?)", new Object[] { UsrId });

            if (UsrStatus != null) {

                UserSts = UsrStatus.toString();

            }

            return UserSts;

       public String ExecUsrPswd(String SignId,String Spswd) {

        DBTransactionImpl dbti = (DBTransactionImpl)getDBTransaction();

        CallableStatement statement =

          dbti.createCallableStatement(("BEGIN "+"cal.Pswd(?,?);" +

                                        "END;"), 0);

        try {

            statement.setString(1,SignId);

            statement.setString(2,Spswd);

            statement.registerOutParameter(2, Types.VARCHAR);

            statement.execute();

            return statement.getString(2);

        } catch (SQLException sqlerr) {

            throw new JboException(sqlerr);

        } finally {

            try {

                if (statement != null) {

                    statement.close();

                }

            } catch (SQLException closeerr) {

                throw new JboException(closeerr);

            }

        }

    }

in my bean i have this

     public void PswdValidator(FacesContext facesContext, UIComponent uIComponent,

                                  Object object) {

          //   String msg =null;

                OperationBinding oBindings = getOperationBinding("ExecUsrPswd");calling a procedure

                OperationBinding oBindingsUsr = getOperationBinding("getUsrStstus");//calling a function

                oBindings.getParamsMap().put("signid",object);

                oBindings.execute();

             

        Object o = oBindings.getResult(); //if the validation paase i what navigate to next inputtext and able to navigate to othe page

                                    //i what to call another screen if the function return status Open this screen is diffirent from the sccren if validation paased

        if(o != null) {

           String msg = o.toString();

                          FacesMessage fm = new FacesMessage(msg);

                          throw new ValidatorException(fm);

              }

                                  }

<af:inputText value="#{bindings.Password.inputValue}"

                                label="Password:"

                                columns="#{bindings.Password.hints.displayWidth}"

                                maximumLength="#{bindings.Password.hints.precision}"

                                shortDesc="#{bindings.Password.hints.tooltip}"

                                id="it1" styleClass="CriticalInputLabelStyle"

                                required="true"

                                autoSubmit="true" secret="true"

                                validator="#{pageFlowScope.SignOnValidation.PswdValidator}">

                    <f:validator/>

                  </af:inputText>

This post has been answered by Ashish Awasthi on May 20 2016
Jump to Answer

Comments

mathguy

To get the sum of numbers in a ROW, you just use the + operator with the column names as operands; don't use SUM(...).
Then: weird column names must be enclosed in DOUBLE-QUOTES, like so:

"2021-01-08"

(those are not two consecutive single-quotes, but a single double-quote character on each side of the column name).
Beware of null, too; unlike the SUM(...) aggregate (which works only on columns -adding values from all rows - the opposite of what you need here), the simple addition operator does not ignore null. Instead, it returns null as the answer. If you want null to be treated as "zero", then you will need to wrap each column name (double-quoted as shown) within NVL(...., 0) before applying the addition operator +
In the end. the formula for the extra column might look something like

nvl("2021-01-01", 0) + nvl("2021-01-02", 0) + ...   as total

or without the NVL if you don't expect null, or if you don't want null to be treated as zero

"2021-01-01" + "2021-01-02" + ....   as total

EDIT:

Looking at it again, you are simply letting PIVOT create the column names. So they aren't simply 2020-01-01 for example; they are already enclosed in single-quotes. If that works for you, fine; then the column names are referenced like so:

"'2020-01-01'"

Happily the code formatting makes it easy to read this. There are double-quote characters at the extremities; then single-quote characters which are part of the column names (as generated by PIVOT).

The alternative is to generate column names without single-quotes. You can do that in PIVOT:

pivot ... for dates in ('2021-01-01' as "2021-01-01", .....)

then PIVOT will use those column names instead of the automatically generated ones. Note that here, too, you must use double-quotes around the weird column names.

User_OMEF8

undefined (0 Bytes)Thanks Mathguy.
I tried the double quotes, but it still produces the same error message (missing right parenthesis). I am not too worried about the null because my count will interpret it to 0 if there are none for that day.

pivot (  
             count(*)
             for(DATES) in ( '2021-01-01', '2021-01-02', '2021-01-03' )
             "2021-01-01" + "2021-01-02" + "2021-01-03"
            )

I think it has to do with my pivot and the "dynamic? (not sure if this is the right word for it)" date columns ('2021-01-01', '2021-01-02', '2021-01-03').

mathguy

Did you read my EDIT (to my first answer)?

Frank Kulash
Answer

Hi,
As Mathguy said, the column names are not 10 characters long, starting with 2 (e.g., "2021-01-01"); they are 12 characters long, starting with single-quote (e.g., "'2021-01-01'"). Another problem is that those column names cannot be used inside the PIVOT clause; you can use them in the SELECT clause.
I suggest using names that don't require double_quotes, such as d_2021_01_01. If you must use non-standard names, then do something like this:

WITH  data_to_pivot  AS
(
      select upper (a.doc_type)                 as DOC_TYPE
      ,      to_char(a.date_time, 'yyyy-mm-dd') as DATES
      from   tableA a
      where  exists ( 
                      select 1 from tableB b 
                      where b.filename = 'ABCXYZ' and to_char(a.id) = b.id
                    ) 
)
SELECT    p.*
,         "'2021-01-01'" + "'2021-01-02'" + "'2021-01-03'" AS total
FROM     data_to_pivot
PIVOT    (   COUNT (*)
         FOR (dates) IN ( '2021-01-01', '2021-01-02', '2021-01-03' )
         ) p
ORDER BY doc_type;

If you'd care to post CREATE TABLE and INSERT statements for some sample data, then I could test this.

Marked as Answer by User_OMEF8 · Jan 8 2021
User_OMEF8

I didn't see it the first time, so I may have already been in the thread before the edit. Thanks again for the help though. I did use the double quotes and got rid of the single quote in the column name like you mentioned. I still have the wrong syntax for the "sum" column.

User_OMEF8

Thanks Frank! Your query did the trick. It looks like I was putting the SUM part in the wrong spot in the query to begin with.

mathguy

Lol, I was looking so closely at the trees, I didn't see the problem with the forest.
I saw the SUM(...) thing, and the way you were trying to reference the column names, and I didn't see where you were doing all these things. As Mr. Kulash pointed out, you can only do that in the SELECT clause, not in PIVOT.

User_OMEF8

Lol, no worries! I was wondering why you were focused on that part, but I figured there must be some type of lesson you were trying to teach me. Thanks again for the help.

Frank Kulash

HI, @user-omef8
This illustrates one of the many reasons why you need to include a little sample data whenever you have a question, so the people who want to help you can test their ideas. You may have several separate problems with a piece of code; you want them all fixed, not just the most obvious one.

User_OMEF8

That is a very valid point. I will try to provide those the next time I post a question. Thanks again for your help. I greatly appreciate it.

1 - 10
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 20 2016
Added on May 19 2016
18 comments
805 views