Hi friends.
i'm having problem to get values of a class member variable which itself is a class and resides inside another class as an array.
Parent class is CA. its one of the member is CB[] class.
my problem was to get values of CB class.
following is the dedtails of my code.
i was using weblogic workshop 8.1, using JSP, NETUI-tag, JPF.
please help me out -- how to get CB's value from CA class in action method.
thanks in advance.
[ if you need any more infos, please ask me for that.]
/******* class CA **********/
public class CA FormData
{
private String AID;
private String AName;
public CB[] cb;
public void setAID (String value) { this.AID= value;}
public void setAName (String value) { this.AName= value;}
public void setCB (CB[] value) { this.cb= value;}
public String getAID (){ return this.AID;}
public String getAName (){ return this.AName;}
public CB[] getCB (){ return this.cb;}
}
/********* Class CB ***********/
public class CB implements Serializable
{
private String BID;
private String BText;
private boolean select;
public void setSelect(boolean value){this.select = value;}
public void setBID (String value) { this.BID= value;}
public void setBText (String value) { this.BText= value;}
public String getBID (){ return this.BID;}
public String getBText (){ return this.BText;}
public boolean isSelect(){return this.select;}
}
/****** pageA.jsp *********/
<netui:form action="CreateTest">
<table>
<tr>
<td colspan="2">Create Tests</td>
</tr>
<tr>
<td>Name</td>
<td><netui:textBox dataSource="{actionForm.AName}" /></td>
</tr>
<tr>
<td colspan="2"> Select CBs</td>
</tr>
<tr>
<td colspan="2">
<netui-data:repeater dataSource="{actionForm.cb}">
<netui-data:repeaterItem>
<tr>
<td><netui:hidden dataSource="{container.item.BID}" />
<netui:checkBox tagId="chb" dataSource="{container.item.select}" /></td>
<td><netui:label value="{container.item.BText}" /></td>
</tr>
</netui-data:repeaterItem>
</netui-data:repeater>
</td>
</tr>
<tr>
<td><netui:button value="Create">Save</netui:button></td>
</tr>
</table>
</netui:form>
/******************************************************/
/**************** pageController.jpf *********************/
public class PageController extends PageFlowController
{
/**
* @common:control
*/
private DBControl dbControl;
/**
* @jpf:action
* @jpf:forward name="create" path="PageA.jsp"
*/
protected Forward goPageA()
{
CAeForm = new CA();
CB[] cb= dbControl.getCBs();
eForm.setCB(cb);
return new Forward("create",eForm);
}
/**
* @jpf:action
* @jpf:forward name="success" path="Default.jsp"
*/
protected Forward CreateTest(CA eForm)
{
eForm.cb= dbControl.getCBs();
String AID = null;
try
{
dbControl.insertCA(eForm.getAName());
AID = dbControl.getExamID(eForm.getAName());
String CBID = null;
for(int i=0; i<eForm.cb.length; i++)
/**** GOT NULLPOINTEREXCEPTION AS "eForm.cb" IS GIVING null RETURN !! ****/
{
if(eForm.cb[i].isSelect())
{
CBID = eForm.cb[i].getBID();
try
{
dbControl.insertCBInA(AID,CBID);
}
catch(SQLException e){String msg = e.getMessage();}
}
}
}
catch(SQLException e){String msg = e.getMessage();}
/******** INSERTION COMPLETE *****************/
return new Forward("success",eForm);
}