• Post Reply Bookmark Topic Watch Topic
  • New Topic

component execution order

 
jeroen dijkmeijer
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I'm facing the following problem: (WSAD 5.1.2, ibm component sets)
I have a dropdownlist which is populated with some entities containt an int (lets call it x) and I have datatable which should render x rows. Everytime I change the value of the dropdownlist the property is set in some dto accessible from the backing bean and the datatable must access this dto property and generate x rows. I implemented a valuechangelistener wich is working fine, but too late. (After the datatable has queried the property) I tried setting the immediate property. Alas to no avail. Anybody an idea? I can solve it in a bit of a clumsy way but it would be nice to control the the order in which events are being fired and intercepted.
regards & tia
Jeroen Dijkmeijer.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show a bit of your code.
 
jeroen dijkmeijer
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use case:
User is presented with a page displaying a dropdownlist and a datatable. User selects a value with associated size from a dropdown. As soon as change is made to dropdown list, the datatable on the (same) page must be rerendered now with the number of rows equal to the associated size in the dropdown.

Some code snippets:
the dropdownlist:
<h:selectOneMenu styleClass="selectOneMenu" id="functionMenu" value="#{pc_CrudClassFP.classFP.functionCode}" valueChangeListener="#{pc_CrudClassFP.handleFunctionMenuValueChange}" onchange="return func_2(this, event);" immediate="true"><f:selectItems value="#{pc_CrudClassFP.classFunctions}" /></h:selectOneMenu>
executes a form.submit on changes and has a valuechangelistener.

the datatable.
<TD><h ataTable styleClass="dataTable" id="id3" value="#{pc_CrudClassFP.valueList}" var="varvalue">

<f:facet name="header">

..
In the backing bean:
dropdownlistener:
public void handleFunctionMenuValueChange(ValueChangeEvent valueChangedEvent) {
// Type Java code to handle value changed event here
// Note, valueChangeEvent contains new and old values
if (logger.isDebugEnabled()) {
logger.debug("handleFunctionMenuValueChange: '" + valueChangedEvent.getNewValue() + "'");
}
String functionCode = (String) valueChangedEvent.getNewValue();
getClassFP().setFunction(SteeringDataDelegate.findClassFunctionByCode(getRealmDate(), functionCode));
..
Getter in backing bean for valuelist:
public List getValueList() {
String functionCode = (String) getFunctionMenu().getValue();
// stupid hack because the datatable using this table is rendered
// before the valuechangelistener is being called.
if (!getClassFP().getFunctionCode()
.equals(functionCode)) {
getClassFP().setFunction(
SteeringDataDelegate.findClassFunctionByCode(
getRealmDate(), functionCode));
if (logger.isDebugEnabled()) {
logger.debug("getValueList changed function: '"
+ functionCode + "' with size "
+ getClassFP().getFunction().getNrParams());
}
int size = getClassFP().getFunction().getNrParams();
...

getValuelist gets called before handleFunctionMenuValueChange which is bad because the table doesn't gets displayed with the newly chosen number of lines. Next time the user chanes value of dropdownlist the previous nr of lines is shown.
How can I control the order of execution?

regards,
Jeroen.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything looks fine to me.

getValuelist gets called before handleFunctionMenuValueChange


That's fine. But whether it is getting called "again" after "handleFunctionMenuValueChange" is important.
Put a debug message inside your getValuelist,setValueList & handleFunctionMenuValueChange.

Is the output like this?
getValuelist
handleFunctionMenuValueChange
setValueList
getValuelist
 
jeroen dijkmeijer
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it does!!!
And the code did screw up because the regeneration of the valuelist was originally surrounded by a null check. So in the first pass the valuelist was created and therefor in secondpass unequal to null so not regenerated.
I'm going to sit in the corner so no one will see my blushing.
Thanx for your time!!!
Jeroen.
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!