Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

While using hx:inputRowSelect all radioButtons getting selected.  RSS feed

 
Dhruba Nag
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We had a hx:inputRowSelect in a hx:columnEx inside a hx:datatableEx. Only one radio button is supposed to get selected at a time.When it was running on was 6.1, it was working fine.But now We are trying to migrate our application to was 8.5.5. The page is getting rendered properly but after clicking on a radio button , if we click on another radio button the previous one does not get deselected. The code is included below.

JSP page:

<hx:dataTableEx border="0" cellpadding="2" cellspacing="0" columnClasses="columnClass1" headerClass="header" footerClass="footerClass" rowClasses="rowClass1, rowClass2" styleClass="dataTableEx" id="VendorRebates" value="#{pc_VendorRebates.rebates}" var="varRebate"
rendered="#{not empty pc_VendorRebates.rebates}" >
<hx:columnEx id="columnEx2">
<hx:inputRowSelect onclick="return radioButtonClick(this, event);"
styleClass="inputRowSelect" id="rowSelect1" selectOne="true"
value="#{pc_VendorRebates.rebateIndexes}"
valueChangeListener="#{pc_VendorRebates.processRebateChanged}"
>
</hx:inputRowSelect>
<f:facet name="header"></f:facet>
</hx:columnEx>
-------
</hx:dataTableEx>

Java code:

pc_VendorRebates == VendorRebatesPage.java

public Integer[] getRebateIndexes() {
setRebateIndexesAllowed = true;
return getManagedBean().getRebateIndexes();
}

public void setRebateIndexes(Integer[] rebateIndexes) {
if (setRebateIndexesAllowed) {
getManagedBean().setRebateIndexes(rebateIndexes);
}
}


public void processRebateChanged(ValueChangeEvent valueChangedEvent) {
getManagedBean().setSelectedContracts(new ArrayList<Contract>());

Integer[] rebateIndexes = null;
// If valueChangedEvent is null then we came from the search or another
// screen not really from selecting a rebate, set the selected rebate
// to the first rebate in this case
if (valueChangedEvent == null) {System.out.println("Event = null");
List<Rebate> rebates = getManagedBean().getRebates();
if (rebates != null && rebates.size() > 0) {
rebateIndexes = new Integer[] {0};
}
} else {
rebateIndexes = (Integer[]) valueChangedEvent.getNewValue();
for(int i = 0; i < rebateIndexes.length; i++){
System.out.println("Rebate Index values are " + rebateIndexes[i]);
}
System.out.println("Event not = null");
rebateIndexes = (Integer[]) valueChangedEvent.getNewValue();
resetContractsSelectBox();
}

if (rebateIndexes != null && rebateIndexes.length > 0) {
Rebate selectedRebate = getManagedBean().getRebates().get(rebateIndexes[0]);
if (!selectedRebate.equals(getManagedBean().getSelectedRebate())) {
getManagedBean().setSelectedRebate(selectedRebate);
refreshContractsSelectItems();
setRebateIndexes(rebateIndexes);
getFacesContext().renderResponse();
}
}
// Added Else condition to set an empty rebate when no rebates is selected
else {
getManagedBean().setSelectedRebate(new Rebate());
}
}


 
Dhruba Nag
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Attaching the code in format

JSP page




Java code:
pc_VendorRebates == VendorRebatesPage.java





 
filip matosic
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
having the same problems,
it seems that the javascript selector that handles the check event is not the same,
use to be new
hX_6.JSFBehaviorRowSelect("form1:tableEx1")
now
hX_6.JSFBehaviorRowSelect("form1")
but still don't know what we have to do to fix this?
Any help appriceated
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with the "hx" tag library, but I can say that valueChangedEventListeners should not presume to think that they have the power to indiscriminately set backing bean properties or interfere with the normal JSF lifecycle (for example, invoking the renderResponse method).

valueChangedEvent listeners work best when they do only things that cannot be done in regular POJO property or action methods.

Beyond that, I see reference to a "radioButton" method, but no actual UI control for radio button.
 
filip matosic
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that it uses javascript to generate radio buttons, but if you turn off script it uses simple radio buttons, as I think should be by default.
So what has to be done is in the inputRowSelect properties set no script to true and voila, works like charm.
<hx:inputRowSelect id="rowSelect1" styleClass="inputRowSelect"
selectOne="true" noscript="true"></hx:inputRowSelect>
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!