Sunday, August 28, 2016

Class Not Found Exception when deploying BPM Process

as usual when any developer meet ClassNotfoundException through his deployment of EAR , he will be confused about the reason of this issues . the first reason might come to your mind is missing jar  , which will be the right solution in most of cases but not this case !

today i have faced the following exception  : 

weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.apache.myfaces.trinidad.webapp.TrinidadConverterELTag

as you may expect i started with looking jars and checking weblogic.xml to find any missing jar or reference without any hope .

finally , the solution came from smart colleague and it was simple and direct and it just recreation the Ear profile and use it to deploy again and everything has worked like charm !


Sunday, August 21, 2016

Fill Multi language Select One Choice from Table using java Bean

In this article i will show how to fill Select one Choice component from database based on Default browser language .
  • Create Table with name "Lov" that contains two languages columns for display text . as show below :
   

  • Create jspx page and create java bean for it
  • inside the java bean define Selecitems object as follow:                                                                             private List listOfItems = new ArrayList();
  • drag drop selectonechoice component to your page the following dialog will appear to determine the list that your SOC will reference to
  • choose First option and click Bind and map to listOfItems in your java bean then click next . in the next form fill the label text and requiredmessagedetails



  • Generate the accessors
  • i suppose that Lov List will be changed based on Browser language , to catch the current language i have added Resource key with name "language"  inside the available Bundles then i will read the value of this key every time i need to check the language .                                                    
                                                                                                                                                 
  • in getListOfItems add the following Code                                                                                   public List getListOfItems() throws SQLException                                                                                                                {                                                                                                                                                                                        Connection DBConn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","user","password");
                          Statement statement = null;                                                                                                                        
                          statement = DBConn.createStatement();                                                                                                    
                          FacesContext context = FacesContext.getCurrentInstance();                                                                        
                          String Lang = context.getApplication().evaluateExpressionGet(context, "#{bundle['language']}", String.class);
                          // or use  Locale browserLocale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
                          // browserLocale.getDisplayLanguage() ;
                          String strQuery =null ;
                          if (Lang=="en")
                             {                                                                                                                                                                
                                  strQuery = "select ID, EN_Name Lov_Name from Lov" ;
                              }
                          else
                             {
                                  strQuery = "select ID, AR_Name Lov_Name from Lov" ;
                              }
                         ResultSet rs = statement.executeQuery(strQuery);
                       
                         while (rs.next())
                            {
                               SelectItem si = new SelectItem();
                               si = new SelectItem();
                               si.setLabel(rs.getString("ID"));
                              si.setValue(rs.getString("Lov_Name"));
                              listOfItems.add(si);
                            }
                return listOfItems;
    }



  • to test your code change the language of Browser to see the effect