【问题标题】:validation in oracle java adforacle java adf中的验证
【发布时间】:2015-10-22 09:23:14
【问题描述】:

1.9.0 我在 java 中如何做这个 key-next 触发器验证

我是这样的,但在 java adf 中

protected PreparedStatement createStatementADF(String query)
{
    PreparedStatement statement=null;
    try {

              /*create transaction for current statemtnt*/
              DBTransaction dbTransaction = (DBTransaction) this.getTransaction();
              statement= dbTransaction.createPreparedStatement(query, 0);
    } catch (SQLException e)
    {
              throw new JboException(e);
    }
    return statement;

}
/*Executes single query*/
protected ResultSet executeQueryADF (String query, Object[] bindVars)
{
          PreparedStatement statement=null;
          ResultSet ret=null;
          try {

              /*create transaction for current statemtnt and resuse it*/
              statement=createStatementADF(query);

              if ((bindVars != null)&&(statement!=null)) {
                  // 2. Loop over values for the bind variables passed in, if any
                  for (int z = 0; z < bindVars.length; z++) {
                      // 3. Set the value of each bind variable in the statement
                      statement.setObject(z + 1, bindVars[z]);
                  }
              }
              // 4. Execute the statement
              ret=statement.executeQuery();
          } catch (SQLException e) {
              throw new JboException(e);
          } finally {
              if (statement != null) {
                  try {
                      // 5. Close the statement
                      statement.close();
                  } catch (SQLException e) {
                  }
              }
          }
          return ret;
}
public void getUsrStatus()
{
        ResultSet rs = null;
        Object[] bindVars = new Object[]{"TestUser"};

        try {
            rs = executeQueryADF("SELECT account_status  FROM  dba_users WHERE  username = ?", bindVars );
            while(rs.next())
            {
                //..... process data
            }
        } catch (Exception e)
        {
        }

    }

我可以在哪里使用 valueChangeListener,我要验证密码并调用程序来验证密码,我必须根据输入的 useid 进行验证

public void labelListener(ValueChangeEvent valueChangeEvent)
  { UIComponent c = valueChangeEvent.getComponent();

    //This step actually invokes Update Model phase for this 
    //component
    c.processUpdates(FacesContext.getCurrentInstance());

    //Jump to the Render Response phase in order to avoid 
    //the validation
    FacesContext.getCurrentInstance().renderResponse();
  }

【问题讨论】:

  • 有问题吗?
  • 是的,我如何在 adf 中进行此验证
  • 您要执行 PL/SQL 还是要将 PL/SQL 转换为 Java?
  • 我如何将 pl/sql 转换为 java adf

标签: java oracle oracle-adf


【解决方案1】:
  1. 创建一个使用以下查询的视图对象 (VO):

    SELECT account_status
          FROM   dba_users
          WHERE  username = :p_username 
    

    其中 p_username 是一个绑定变量,并将 VO 添加到您的应用程序模块 (AM)

  2. 在您的 AM 中,您需要创建一个获取 VO 的新方法, 设置绑定变量并执行VO。在这里,您通过检查行数并查看状态等是否正确来进行验证。

根据您的用例,您应该在 AM 中公开该方法(可能返回布尔值或字符串)。将该方法添加到您的绑定中,并在用户执行某些操作(单击按钮)时执行它。使用您的方法的结果,您可以进行一些导航或显示错误。 (也可以选择抛出异常)。

编辑: 您可以将您的 PL/SQL 移动到一个函数/过程中并从您的 AM 中执行它。非常好的前任:http://www.baigzeeshan.com/2010/05/calling-plsql-procedure-and-function-in.html

【讨论】:

  • 我什么时候调用该程序并执行此操作
  • IF :work.accnt_stat = 'OPEN' 然后 validate_pswd('T', 'dbusername', null, null, passwd, wrk_err_ind, wrk_err_msg); IF nvl(wrk_err_,'N') = 'Y' THEN message(wrk_msg);提高 form_trigger_failure;如果结束;
猜你喜欢
  • 2023-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-06
  • 1970-01-01
  • 2022-01-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多