0 Replies Latest reply on Jun 21, 2011 1:32 PM by Val Sw

    Displaying error message returned from external jar

    Val Sw Expert
      Hi,

      We have seam application working perfectly fine... I need help is displaying any error message from external jar. After transaction success event in Seam (i.e. save/ update), we are using @Observer to call external jar

      Env : jboss-4.2.3, jboss-seam-2.0.2.SP1

      Situation :
      Using @Observer, I am calling a function in External jar (non-seam) which returns some message. On the basis of the message returned from external jar I need to re-render the page if there is any error message (assuming message string will contain "Error" if there is any error).
      I tried the below code and navigation rule (which I am sure is wrong) but not sure how and where to define the navigation rule after afterTransactionSuccess

      Please suggest what will be the best approach.

      @Name("testHome")
      public class TestHome extends EntityHome<Test> {
           public String persist(){
                String persistResult = null;
                persistResult=super.persist();               

                return persistResult;
           }
      }

      @Name("externalApplicationInvoker")
      @Scope(ScopeType.STATELESS)
      public class ExternalApplicationInvoker
      {
           @Observer("org.jboss.seam.afterTransactionSuccess.TestExperiment")
           public String testSavedOrUpdated() {
                 returnMessage = executeExternalJar(arg1, arg2);          
                 if(returnMessage.contains("Error")){
                      log.info("ExternalApplicationInvoker.testSavedOrUpdated(), returnMessage contains ERROR");
                      return "returnMessageError";
                 }else{
                      return returnMessage;
                 }          
           }

           public String executeExternalJar(String arg1, String arg2) {
                String datasetGeneratedMessage = null;
                ExternalJar externalJar=new ExternalJar();
                datasetGeneratedMessage = externalJar.runProcess(args...);
                return datasetGeneratedMessage;
           }
      }


      <navigation from-action="#{testHome.persist}"> also tried <navigation from-action="#{externalApplicationInvoker.testSavedOrUpdated}">  
           <rule if-outcome="returnMessageError">
                <render view-id="/TestEdit.xhtml">
                     <message severity="error">                       
                          Error processing external jar.... etc
                     </message>
                </render>             
           </rule> 
      </navigation>


      Regards