如何在java adf中显示数据库返回错误消息

时间:2015-10-27 11:01:10

标签: java oracle plsql oracle-adf

1.1.9.0我有方法调用程序,我在显示那些在我的程序中返回的msg怎么办

我的方法是

public void validUsr(FacesContext facesContext, UIComponent uIComponent, Object object){

           String inputString =object.toString().toUpperCase();

       // executeQueryADF("cal.SignId(?)",new Object[] {inputString});

        callPerformSdmsLogon("cal.SignId(?)",new Object[] {inputString});

    }

这是我的程序定义

的方式

procedure SignId(p_signid varchar2,PROC_ERR_MSG OUT varchar2)

2 个答案:

答案 0 :(得分:1)

我不确定天气我是否理解正确但如果您想要显示消息,则需要以下内容:

public void showMessage(String messageText) {
        FacesMessage fm = new FacesMessage(messageText);
        fm.setSeverity(FacesMessage.SEVERITY_INFO);
        FacesContext context = FacesContext.getCurrentInstance();
        context.addMessage(null, fm);
}

此处有来源https://mjabr.wordpress.com/2011/07/29/how-to-show-afmessage-programatically/

答案 1 :(得分:0)

  

public void validUsr(FacesContext facesContext,UIComponent uIComponent,Object object){String inputString = object.toString()。toUpperCase(); // executeQueryADF(" calmain.SignId(?)",new Object [] {inputString}); String msg = null; callPerformSdmsLogon(" calmain.SignId(?,?)",new Object [] {inputString,msg}); if(msg!= null){// System.out.println(msg);抛出新的ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,msg,null)); }}

如果您只是想显示您的消息,则不必抛出异常,但您可以执行以下操作:

public void validUsr(FacesContext facesContext, UIComponent uIComponent, Object object){ 
 String inputString =object.toString().toUpperCase(); 
 String msg = null; 
 callPerformSdmsLogon("calmain.SignId(?,?)",new Object[] {inputString,msg}); 
 if(msg != null){ 
    showMessage(msg); 
 } 
}

public void showMessage(String messageText) {
    FacesMessage fm = new FacesMessage(messageText);
    fm.setSeverity(FacesMessage.SEVERITY_INFO);
    FacesContext context = FacesContext.getCurrentInstance();
    context.addMessage(null, fm);
}

我仍然不确定你想要达到什么目的。