[Bug #1216] Fix issue chaning code to check allocation resource radio
The problem was caused becase of when radio was added to row the checked value was reseted (due to a change in ZK5). Change the way to makr the radio as checked, now it's done after the radio is added to the row. FEA: ItEr75S04BugFixing
This commit is contained in:
parent
ff185b9648
commit
7220951b74
2 changed files with 18 additions and 24 deletions
|
|
@ -24,9 +24,6 @@ import java.util.Arrays;
|
|||
import org.apache.commons.lang.Validate;
|
||||
import org.navalplanner.business.planner.entities.CalculatedValue;
|
||||
import org.navalplanner.web.planner.allocation.ResourceAllocationController.CalculationTypeRadio;
|
||||
import org.zkoss.ganttz.timetracker.ICellForDetailItemRenderer;
|
||||
import org.zkoss.ganttz.timetracker.OnColumnsRowRenderer;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.HtmlMacroComponent;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
|
@ -37,6 +34,8 @@ import org.zkoss.zul.Label;
|
|||
import org.zkoss.zul.ListModelList;
|
||||
import org.zkoss.zul.Radio;
|
||||
import org.zkoss.zul.Radiogroup;
|
||||
import org.zkoss.zul.Row;
|
||||
import org.zkoss.zul.RowRenderer;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -90,22 +89,26 @@ public class AllocationConfiguration extends HtmlMacroComponent {
|
|||
calculationTypesGrid = (Grid) getFellowIfAny("calculationTypesGrid");
|
||||
calculationTypesGrid.setModel(new ListModelList(Arrays
|
||||
.asList(CalculationTypeRadio.values())));
|
||||
calculationTypesGrid.setRowRenderer(OnColumnsRowRenderer.create(
|
||||
calculationTypesRenderer(), Arrays.asList(0)));
|
||||
calculationTypesGrid.setRowRenderer(getCalculationTypesRenderer());
|
||||
}
|
||||
|
||||
private ICellForDetailItemRenderer<Integer, CalculationTypeRadio> calculationTypesRenderer() {
|
||||
return new ICellForDetailItemRenderer<Integer, CalculationTypeRadio>() {
|
||||
private RowRenderer getCalculationTypesRenderer() {
|
||||
return new RowRenderer() {
|
||||
|
||||
@Override
|
||||
public Component cellFor(Integer column, CalculationTypeRadio data) {
|
||||
if (formBinder == null) {
|
||||
return data.createRadio(null);
|
||||
public void render(Row row, Object data) throws Exception {
|
||||
CalculationTypeRadio type = (CalculationTypeRadio) data;
|
||||
|
||||
Radio radio = type.createRadio();
|
||||
row.appendChild(radio);
|
||||
|
||||
if (formBinder != null) {
|
||||
if (type == CalculationTypeRadio.from(formBinder
|
||||
.getCalculatedValue())) {
|
||||
radio.setChecked(true);
|
||||
}
|
||||
radio.setDisabled(formBinder.isAnyManual());
|
||||
}
|
||||
Radio radio = data.createRadio(CalculationTypeRadio
|
||||
.from(formBinder.getCalculatedValue()));
|
||||
radio.setDisabled(formBinder.isAnyManual());
|
||||
return radio;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -415,22 +415,13 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
public abstract Component input(
|
||||
ResourceAllocationController resourceAllocationController);
|
||||
|
||||
public Radio createRadio(CalculationTypeRadio calculationTypeRadio) {
|
||||
public Radio createRadio() {
|
||||
Radio result = new Radio();
|
||||
result.setLabel(getName());
|
||||
result.setValue(toString());
|
||||
result.setChecked(isSameCalculationTypeRadio(calculationTypeRadio));
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isSameCalculationTypeRadio(
|
||||
CalculationTypeRadio calculationTypeRadio) {
|
||||
if (calculationTypeRadio != null) {
|
||||
return name().equals(calculationTypeRadio.name());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private final CalculatedValue calculatedValue;
|
||||
|
||||
private CalculationTypeRadio(CalculatedValue calculatedValue) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue