on 01-30-2008 10:06 AM
Hi All
I have a requirement in which i have to query a database
My Front End is in WD and I am using a java bean model which interacts with stateless session bean fro there connectivity with database happens.
but when in component controller i set the variables of bean model it throws me Null Pointer exception..the value which i am setting when displayed is all right but when i use say
wdContext.nodeMyCommandBean().currentMyCommandBeanElement().setDeptName(dpname);
here MyCommandBean is my java class which i am using as a model and deptName is its one of the variable
It throws a Null Pointer Exception here whereas when i display "dpname " to chk whether it has some data it gives me correct value
Please Help
Thanks
Hi Monika,
Always check the variable value not equal to null and then do process.
if(dpname!=null)
wdContext.nodeMyCommandBean().currentMyCommandBeanElement().setDeptName(dpname);
Regards, Suresh KB
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
just check currentMyCommandBeanElement(). is null or not before accessing the
setDeptName(dpname);
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suresh
I wrote this line of code in wdInit of Component Controller :
wdContext.nodeMyCommandBean().bind(new MyCommandBean());
Now whats the new problem is that when i deploy and run my application it doestn't display my UI's and when i remove this line of code i am able to see my UI's
I think problem is with Java Bean class :
This is the constructor which i wrote in java class which i am using as a model
public MyCommandBean(){
try{ InitialContext ctx= new InitialContext();
objDepartmentBean = (DepartmentBean)ctx.lookup("jdbc/MySessionBean");
}catch(Exception e){
e.printStackTrace();
}
}
Here DepartmentBean is a Session Bean in a EJB project.
Please suggest some solution
Thanks
Hi Monika,
Go through this link.
public class MyCommandBean {
private int multiplier;
private ssn;
String private double bonusAmount;
private String message;
BonusCalculatorLocal theCalculator = null;
BonusCalculatorLocalHome home = null;
public MyCommandBean() throws CreateException {
//looks up the session bean and creates the Home interface
try {
InitialContext ctx = new InitialContext();
home = (BonusCalculatorLocalHome)ctx.lookup("localejbs/MySessionBean");
<b>theCalculator = home.create();</b>
} catch (Exception namingException) {
namingException.printStackTrace();
}
}
}
Regards,
Mithu
Hi Mithu
Thanks for ur reply. When i write wdContext.nodeMyCommandBean().bind(new MyCommandBean()); line of code in my Component controller it does not display my UI's but when i remove this from there thn m able to see my Ui's when application deployed and run....
this time in my bean model i wrote these lines of code:
public MyCommandBean(){
try{ InitialContext ctx= new InitialContext();
home = (DepartmentLocalHome)ctx.lookup("jdbc/MySessionBean");
objDepartmentLocal = home.create();
}catch (Exception namingException) {
namingException.printStackTrace();
}
}
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.