بتاريخ: 17 يونيو 201015 سنة comment_194862 Dear All this is Example i made for all people here to Login Form Using DB User Concept with Dynamic any number of Screens & Users, i used BC,EJB & JSF LanguagesFirst BC Customized Scripts public String GetURL(String Name) {String URL = "-1";getMyTables1().setWhereClause("name like '" + Name + "'" +" AND active = 'Y'");try {getMyTables1().executeQuery();} catch (JboException e) {throw new JboException(e.getMessage());}if (getMyTables1().getRowCount() > 0) {while (getMyTables1().hasNext()) {Row TableRow = getMyTables1().next();URL = (String)TableRow.getAttribute("Url");}} else {URL = "-1";}return URL;}public void CheckUserForms(String User, int Size) {getAllUserForms2().setMaxFetchSize(Size);getAllUserForms2().defineNamedWhereClauseParam("UName", null, null);getAllUserForms2().setNamedWhereClauseParam("UName", null);getAllUserForms2().setNamedWhereClauseParam("UName", User);try {getAllUserForms2().executeQuery();} catch (JboException e) {throw new JboException(e.getMessage());}}public String UserNamePassword(String User, String Password) {String FinalResult = "0";try {Class.forName("oracle.jdbc.driver.OracleDriver");} catch (ClassNotFoundException e) {e.printStackTrace();}Connection conn = null;try {conn =DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", User,Password);} catch (SQLException e) {FinalResult = "0";}try {if (conn.isValid(20) == true) {FinalResult = "1";} else {FinalResult = "0";}} catch (SQLException e) {FinalResult = "0";}return FinalResult;}public void NewCreateInsert() {Row NewRow = getAllUserForms().createRow();getAllUserForms().insertRow(NewRow);}public void afterConnect() {getAllUserForms2().setMaxFetchSize(0);getAllUserForms2().executeQuery();}public void list(String NamePar) {if (NamePar == null){System.out.println("No Need to write code here, just for interface");}Second EJB Customized Scriptspublic BindingContainer getBindings() {return BindingContext.getCurrent().getCurrentBindingsEntry();}public String Login() throws SQLException {BindingContainer bindings = getBindings();String Final = null;// Checking user Name & PasswordObject error = "Please Enter a Valid User Name, Password & Access. ";if (getIt1().getValue() != null && getIt2().getValue() != null &&getIt3().getValue() != null) {OperationBinding operationBinding0 =bindings.getOperationBinding("UserNamePassword");operationBinding0.getParamsMap().put("User", getIt1().getValue());operationBinding0.getParamsMap().put("Password",getIt2().getValue());Object result0 = operationBinding0.execute();if (!operationBinding0.getErrors().isEmpty() ||result0.toString() == "0") {getAot1().setValue(error.toString());} else {// Fetting URLOperationBinding operationBinding =bindings.getOperationBinding("GetURL");operationBinding.getParamsMap().put("Name",getIt3().getValue());Object result = operationBinding.execute();System.out.println(getSoc1().getValue());if (!operationBinding.getErrors().isEmpty()) {Final = null;getAot1().setValue(null);getIt1().setValue(null);getIt2().setValue(null);getSoc1().setValue(null);}getSoc1().setValue(null);if (result != null) {Final = result.toString();}}} else {if (getIt1().getValue() == null) {Alert(it1, "Login Error", "Please, Enter Valid User Name");}if (getIt2().getValue() == null) {Alert(it2, "Login Error", "Please, Enter Valid User Password");}}return Final;}public void Alert(UIComponent MyComponent, String ErrorHeader,String ErrorDetail) {FacesContext facescontext = FacesContext.getCurrentInstance();if (MyComponent != null) {FacesMessage MyMessage =new FacesMessage(FacesMessage.SEVERITY_ERROR, ErrorHeader,ErrorDetail);facescontext.addMessage(MyComponent.getClientId(facescontext),MyMessage);((RichInputText)MyComponent).setValue(null);((RichInputText)MyComponent).setRequired(true);((RichInputText)MyComponent).setValid(false);}}public void Password_validator(FacesContext facesContext,UIComponent uIComponent, Object object) {if (object == null) {((RichInputText)uIComponent).setRequired(true);((RichInputText)uIComponent).setValid(false);}}public void User_validator(FacesContext facesContext,UIComponent uIComponent, Object object) {if (object != null) {System.out.println(object.toString().toUpperCase());BindingContainer bindings = getBindings();OperationBinding operationBinding0 =bindings.getOperationBinding("CheckUserForms");operationBinding0.getParamsMap().put("User",object.toString().toUpperCase());operationBinding0.getParamsMap().put("Size", 100);Object result0 = operationBinding0.execute();if (!operationBinding0.getErrors().isEmpty()) {Alert(uIComponent, "Validation Error","Please, Enter Valid User Name");}} else {((RichInputText)uIComponent).setRequired(true);((RichInputText)uIComponent).setValid(false);}getIt2().setValue(null);}Print ScreensScreen1Screen2Screen3Screen4Screen5Screen6Full ProjectLogin Attached, Print Screens , Full Source Code , My Test DB ScriptMany Thanks تقديم بلاغ
بتاريخ: 18 أبريل 20169 سنة comment_273678 سلام عليكم باش مهندس .....جزاك الله خيرا على هذا العمل ولكن الروابط لاتعمل .... الرجاء اعادة ارسال الروابط ان امكن ذلك ولكم جزيل الشكر تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.