>>>>> -------------------- >>>>>
This user list is closed. Please post your questions to the GlassFish
webtier forums.
<<<<< -------------------- <<<<<
I am working with JSF and Java 1.6.0_14 using Netbeans 6.7.1. I am building
my HtmlPanelGrid dynamically in the following way.
public void addItemNumbers(ValueChangeEvent changeEvent)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();
List<UIComponent> children = itemPanel.getChildren();
children.clear();
srchDesc= "";
srchItemno = (String)changeEvent.getNewValue();
String[][] itemArray = getItemsByItemno( srchItemno);
HtmlCommandLink outputItemno;
UIParameter id;
for ( int count = 0; count < itemArray.length; count++)
{
// ID REQUIRED
id = new UIParameter();
id.setName("id" + itemArray[count][0]);
id.setValue( itemArray[count][0]);
// ITEM NUMBER
outputItemno = (HtmlCommandLink) application.createComponent(
HtmlCommandLink.COMPONENT_TYPE);
outputItemno.setValue( itemArray[count][0]);
String action = "#{ itemcountbean.listSetup}";
MethodExpression methodExpression =
FacesContext.getCurrentInstance().getApplication().getExpressionFactory().
createMethodExpression(FacesContext.getCurrentInstance().getELContext(),
action, String.class,
new Class<?>[0]);
outputItemno.setActionExpression( methodExpression);
ValueExpression valueEx =
application.getExpressionFactory().createValueExpression(facesContext.
getELContext(),
"#{itemcountbean.itemno}", String.class);
outputItemno.setValueExpression( itemArray[count][0], valueEx );
outputItemno.setStyle( "color: blue");
outputItemno.getChildren().add(id);
children.add( outputItemno);
// ITEM DESCRIPTION
HtmlOutputText outputItemDesc = (HtmlOutputText) application
.createComponent( HtmlOutputText.COMPONENT_TYPE);
outputItemDesc.setValue( itemArray[count][1]);
outputItemDesc.setStyle( "color: blue");
outputItemDesc.getChildren().add(id);
children.add( outputItemDesc);
}
logger.log( Level.FINER, "HtmlCommandLink item panel populated");
}
This is displayed by the JSP page with the following code:
<h:panelGrid id="itemPanel"
binding="#{ item.itemPanel}"
columns="2" border="1" cellspacing="5" />
The itemcountbean has the following coding in itemcountbean:
public String listSetup() {
logger.log( Level.INFO, "itemcountbean.listSetup");
logger.log( Level.INFO, "itemcountbean.itemno ["+this.itemno+"]");
...
return "itemcount_list";
}
Everything appears to be working except transferring via the 'binding' that
is suppose to occur (if my understanding is correct) using the
ValueExpression valueEx =
application.getExpressionFactory().createValueExpression(facesContext.
getELContext(),
"#{itemcountbean.itemno}", String.class);
outputItemno.setValueExpression( itemArray[count][0], valueEx );
part of the code.
And my
logger.log( Level.INFO, "itemcountbean.listSetup");
logger.log( Level.INFO, "itemcountbean.itemno ["+this.itemno+"]");
log returns
itemcountbean.listSetup
itemcountbean.itemno [null]
I have read through the JavaDocs to attempt to understand establishing the
binding of ' #{itemcountbean.itemno} ' in the correct manner. I have
searched dozens of sites trying to determine my error(s). Some advice was as
little as 'Read the JavaDocs', but most was on binding before the JSF and/or
NBs requiring use of the ValueExpression and setValueExpression. Most of the
answers are 2-3 years old.
Would someone please help me in completion of binding/transferring my value
from my HtmlCommandLink to be used in the backing bean? A tutorial, a
book, other Q/A I have missed, or just correct my misunderstanding.
Thank you.
rdb
--
View this message in context: http://old.nabble.com/JSF---Binding-Dynamically-built-HtmlPanelGrid-HtmlCommandLink-to-backing-bean.-tp26269605p26269605.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.