بتاريخ: 18 مايو 20169 سنة comment_274819 السلام عليكم ورحمة الله انا عندى شاشه لتغيير الباسورد بس بيقولى ف خطأ فى هذا الكود اللى عندو فكره يساعدنى شاكره تعاونكم معى مكان الخطأ انا اشرت عليه package view; import com.bea.common.security.xacml.context.Response; import java.io.IOException; import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import model.AppModuleImpl; import model.UserInfo; import oracle.adf.view.rich.component.rich.RichDocument; import oracle.adf.view.rich.component.rich.RichForm; import oracle.adf.view.rich.component.rich.input.RichInputText; import oracle.adf.view.rich.component.rich.nav.RichCommandButton; import oracle.jbo.ApplicationModule; import oracle.jbo.client.Configuration; public class Login { private String username; private String password; private RichForm f1; private RichDocument d1; private RichInputText it1; private RichInputText it2; private RichCommandButton cb1; //change pass private String oldpass; private String newpass; private String confirmpass; private String mesg; private Object db; public void setF1(RichForm f1) { this.f1 = f1; } public RichForm getF1() { return f1; } public void setD1(RichDocument d1) { this.d1 = d1; } public RichDocument getD1() { return d1; } public void setUsername(String username) { this.username = username; } public String getUsername() { return username; } public void setPassword(String password) { this.password = password; } public String getPassword() { return password; } public void setIt1(RichInputText it1) { this.it1 = it1; } public RichInputText getIt1() { return it1; } public void setIt2(RichInputText it2) { this.it2 = it2; } public RichInputText getIt2() { return it2; } public void setCb1(RichCommandButton cb1) { this.cb1 = cb1; } public RichCommandButton getCb1() { return cb1; } public String loginaction() throws IOException { // Add event code here... FacesMessage message; FacesContext context = FacesContext.getCurrentInstance(); String amDef = "model.AppModule"; String config = "AppModuleLocal"; ApplicationModule ami = Configuration.createRootApplicationModule(amDef,config); AppModuleImpl am = (AppModuleImpl)ami; UserInfo user = am.login(username, password); if (user == null){ message = new FacesMessage(FacesMessage.SEVERITY_ERROR,"User not fond",""); }else { message = new FacesMessage(FacesMessage.SEVERITY_INFO,"User fond" + user.getUsername(),""); context.getExternalContext().getSessionMap().put("username", user); context.getExternalContext().getSessionMap().put("username",user.getUsername()); context.getExternalContext().redirect("changepass.jsf"); //context.getExternalContext().redirect("mai.jsp"); } context.addMessage("", message); return null; } public String cb1_action() { String ch="Update Users SetPassword='"+getNewpass()+"' Where UserName='"+getUsername()+ "' and Password='"+getOldpass()+"' "; if(getNewpass().equals(getConfirmpass() )) { ----------------------------------------------------------this is error if (db.RunUpdate(ch) == 1){ ----------------------------------------------------------------------------------------------------- setMesg("password has been changed"); } else setMesg("old password in correct try again"); //}else //setMesg("password on match"); // else //Response.sendRedirect("login.jsp"); return null; } } public String getOldpass() { return oldpass; } public void setNewpass(String newpass) { this.newpass = newpass; } public String getNewpass() { return newpass; } public void setConfirmpass(String confirmpass) { this.confirmpass = confirmpass; } public String getConfirmpass() { return confirmpass; } public void setMesg(String mesg) { this.mesg = mesg; } public String getMesg() { return mesg; } public void setOldpass(String oldpass) { this.oldpass = oldpass; } } تقديم بلاغ
بتاريخ: 21 مايو 20169 سنة كاتب الموضوع comment_274926 (db.RunUpdate(ch اخى مشكلتى ف هذه الجمله ماقادر يفهمها تقديم بلاغ
بتاريخ: 22 مايو 20169 سنة comment_274965 من المؤكد أنه (ماقادر يفهمها) لإن الطريقة المتبعة خطأ وكود الـ update خطأ وغير مكتمل من الخطأ التعامل بهذه الطريقة من الشاشة مع قاعدة البيانات مباشرة؟؟؟ّ!!! في الكود الذي كتبتيه لنا بجملة update بأخذ المدخلات مباشرة من الشاشة إلى قاعدة البيانات!!! في سطر ch = جملة update !!! هذا خطأ public String cb1_action() { String ch="Update Users SetPassword='"+getNewpass()+"' Where UserName='"+getUsername()+ "' and Password='"+getOldpass()+"' "; if(getNewpass().equals(getConfirmpass() )) { ----------------------------------------------------------this is error if (db.RunUpdate(ch) == 1) { ------------------------------------------------------------------------- setMesg("password has been changed"); } else setMesg("old password in correct try again"); //}else //setMesg("password on match"); // else //Response.sendRedirect("login.jsp"); return null; } } تقديم بلاغ
بتاريخ: 22 مايو 20169 سنة كاتب الموضوع comment_274970 السلام عليكم ياباشمهندسه معنى كلامك انو الا اعرفها بمتغير واناديها ولا الطريقه الصحيحه ايه تقديم بلاغ
بتاريخ: 22 مايو 20169 سنة كاتب الموضوع comment_274972 السلام عليكم ياباشمهندس ف الخطأ بيقولى create variable db create fild db invert if statement negate expression db.RunUpdate(ch) == 1) تقديم بلاغ
بتاريخ: 22 مايو 20169 سنة كاتب الموضوع comment_274978 السلام عليكم ياجماعه ده رابط الفيديو الاشتغلت منه تقديم بلاغ
بتاريخ: 22 مايو 20169 سنة comment_274989 الأفضل تغيير طريقة الاستدعاء واستخدام PreparedStatement تقديم بلاغ
بتاريخ: 23 مايو 20169 سنة كاتب الموضوع comment_275040 السلام عليكم ياباشمهندس PreparedStatement وسيطه بين الجافا والsql ام ماذا تقديم بلاغ
بتاريخ: 1 يونيو 20169 سنة كاتب الموضوع comment_275332 السﻻم عليكم ممكن مثال او مشاركه توضحprepered statmentاذاا امكن تقديم بلاغ
بتاريخ: 1 يونيو 20169 سنة comment_275333 يمكنك مراجعة الفيديوهات الخاصة بالجافا فيها مثال عنها تقديم بلاغ
بتاريخ: 1 يونيو 20169 سنة comment_275335 العفو لكن أرجو فصل كلمة إن عن كلمة شاء الصحيح إن شاء الله تقديم بلاغ
بتاريخ: 2 يونيو 20169 سنة comment_275361 Change Password update statement تأخذ القيمة الجديدة من Input text -------------------------------------- Good Luck. تقديم بلاغ
بتاريخ: 2 يونيو 20169 سنة كاتب الموضوع comment_275370 اخى Update statement داله ام مازا علما بانى مبتدئه ف الجافا والadfممكن توضيح اكثر والinpur textاخدو مباشر من datacontroler ؟ تقديم بلاغ
بتاريخ: 4 يونيو 20169 سنة comment_275417 يجب دراسة PreparedStatement أولاً حيث أن كل أسئلتك ستكون مجابة بعد دراستها تقديم بلاغ
بتاريخ: 4 يونيو 20169 سنة comment_275426 أعتذر أنه تأخرت عن إجابتك على الخاص فعندما أرسلت لي أنا كنت مسافرة لإداء العمرة ، واليوم حتى وصلت حسناً ، إليك الطريقة الصحيحة بعمل الـ update وطريقة الإستدعاء لها في الـ AppModuleImpl نكتب method التي تقوم بعمل الـ update وليكن إسمها udpatePassword وحسب الكود التالي public UserInfo udpatePassword(String password,String userName) { PreparedStatement stat = null; String sql = "update users set password= ? where user_name=?"; try { stat =getDBTransaction().createPreparedStatement(sql,1); stat.setString(1,password); stat.setString(2,userName); stat.executeUpdate(); getDBTransaction().commit(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (SQLException sqlerror) { // TODO: Add catch code sqlerror.printStackTrace(); } } return null; } الآن حتى نستدعي method الـ update التي كتبناها في أعلاه إذن في الشاشة نعمل زرار له action أكيد وبداخله نكتب الكود التالي public String updateAction() { try { FacesContext context = FacesContext .getCurrentInstance(); Application app = context.getApplication(); ValueBinding bind = app.createValueBinding("#{data.AppModuleDataControl.dataProvider}"); AppModuleImpl am = (AppModuleImpl)bind.getValue(context); am.udpatePassword(password,userName); FacesMessage msg = new FacesMessage ("Password was successfully changed"); context.addMessage(null, msg); } catch (Exception e) { e.printStackTrace(); FacesContext context = FacesContext .getCurrentInstance(); FacesMessage msg = new FacesMessage ("An Error Occurred"); context.addMessage(null, msg); } return null; } وإن شاء الله مع القراءة والإطلاع على الإيعازات الخاصة بالتعامل مع قواعد البيانات وطريقة إستخدامها ومع الكود الذي كتبته سيتضح إليك الموضوع تقديم بلاغ
بتاريخ: 5 يونيو 20169 سنة كاتب الموضوع comment_275457 يجب دراسة PreparedStatement أولاً حيث أن كل أسئلتك ستكون مجابة بعد دراستها ان شاء الله ياباشمهندس جزاك الله عنا كل خير وجارى الدراسه فى PreparedStatement تقديم بلاغ
بتاريخ: 5 يونيو 20169 سنة كاتب الموضوع comment_275458 باشمهندسه ميسم ربنا يتقبل منك صالح الاعمال وجزاك الله خيرا على الرد تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.