If you define managed bean in the faces-config.xml, then the bean is available to you in the JSF context. You don't need the jsp:useBean declaration. If you really want to use a standalone bean which does not interact with JSF anyhow, then you may use the jsp:useBean declaration for it. But why doing it this way if JSF can do it for you?
You may find the Java EE tutorial useful: http://java.sun.com/javaee/5/docs/tutorial/doc/
It covers JSP as well as JSF.
Thanks....would you please listen to my problem and help me find out the solution in JSF? On a JSF page I have a datatable where data get populated dynamically from database. With every row of the table I put two controls to accept data from user- a selectOneMenu tag or an inputText tag based on value from database. So, selectOneMenu or inputText maybe more than one in the datatable. For selectOneMenu or inputText I'm keeping only one bean property. Now, I want to add the values in list accepted in selectOneMenu or inputText because I've to send these values to database.
The datatable is as follows:
<t:dataTable styleClass="standardTable" headerClass="standardTable_Header" footerClass="standardTable_Header" rowClasses="standardTable_Row1,standardTable_Row2" columnClasses="standardTable_Column,standardTable_ColumnCentered,standardTable_Column" id="data" var="rmqc" value="#{rawmaterialqcdetails.allRMQCDetailByID}" preserveDataModel="true">
<h:column>
<f:facet name="header">
<h:outputText value="Test"/>
</f:facet>
<h:inputTextarea value="#{rmqc.test}" rows="6" cols="35" readonly="true"></h:inputTextarea>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Specification"/>
</f:facet>
<h:inputTextarea value="#{rmqc.specification}" rows="6" cols="35" readonly="true"></h:inputTextarea>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Result"/>
</f:facet>
[b]<f:subview id="resultc" rendered="#{rmqc.result=='c'}">
<h:selectOneMenu id="comply" styleClass="selectOneMenu" value="#{rawmaterialqcdetails.testValueC}">
<f:selectItem itemLabel="Complies" itemValue="complies"/>
<f:selectItem itemLabel="Does not Comply" itemValue="compliesnot"/>
</h:selectOneMenu>
</f:subview>[/b]
[b]<f:subview id="resulti" rendered="#{rmqc.result=='i'}">
<h:inputText id="input" size="20" styleClass="textbox" value="#{rawmaterialqcdetails.testValueI}"/>
</f:subview>[/b]</h:column>
</t:dataTable>
Look in selectOneMenu I'm accepting value in testValueC which is a string bean property and in inputText I'm accepting value in testValueI which is a float. Both these twocontrols might appear more than once. So, my aim is to add testValueC in one list and testValueI in another list.
The bean code:
private float testValueI;
private String _testValueC;
private List _testValListC;
private List _testValListI;
public List getTestValListC()
{
_testValListC.add(getTestValueC());
return this._testValListC;
}
public void setTestValListC(List _testValListC)
{
this._testValListC = _testValListC;
}
public List getTestValListI()
{
_testValListI.add(getTestValueI());
return this._testValListI;
}
public void setTestValListI(List _testValListI)
{
this._testValListI = _testValListI;
}
public String getTestValueC()
{
//testValListC.add(_testValueC);
return this._testValueC;
}
public void setTestValueC(String _testValueC)
{
this._testValueC = _testValueC;
}
public float getTestValueI()
{
return this.testValueI;
}
public void setTestValueI(float testValueI)
{
this.testValueI = testValueI;
}
But I can't do this. Do you have any idea of getting around this?
Regards
Sorry there is no clearity in your problem. Actually what is you objective.
After seeing your problem what i can suggest is binding your <h:dataTable> to UIDATA may help u out of these. If ur not familiar with UIDATA read some tutorials on it. The UIDATA provides a way to access <h:dataTable> row through the action binding methods of a backing bean.
Thanks....I'm trying to make you understand what I meant. Look in selectOneMenu tag the value is accepted in testValueC bean property and in inputText tag the value is accepted in testValueI bean property. Now I want to add this testValueC to a list testValListC bean property and testValueI to a list testValListI bean property every time data is accepted on these two properties. Do you have any idea?
I'm looking for that UIDATA you suggested to get around this.
Thanks