I followed the suggestion from Javier, but with a variation.
As the number of properties to hide/reveal is not small, I tried to define a view for each type of configuration (I have only three types).
The code is as follows:
package net.mcoletti.glc.guim.actions;
import java.util.*;
import org.openxava.actions.*;
import net.mcoletti.glc.guim.*;
/**
* Adapts the view used to edit the item according to the item type, in order to
* hide the properties that ere unnecessary and avoid errors.
*
* @author mcoletti
*
*/
public class OnChangeTipoCertificato extends OnChangePropertyBaseAction {
@Override
public void execute() throws Exception {
CertificatoDiPagamento.TipoCertificato value = (CertificatoDiPagamento.TipoCertificato) getNewValue();
if (value == null) return;
if (value.equals(CertificatoDiPagamento.TipoCertificato.ANTICIPO)) {
Map mapIndexValues = getView().getKeyValuesWithValue();
getView().setViewName("anticipo");
getView().setValues(mapIndexValues);
getView().setValue("tipoDiCertificato",value);
}
else {
Map mapIndexValues = getView().getKeyValuesWithValue(); /
getView().setViewName("default");
getView().setValues(mapIndexValues);
getView().setValue("tipoDiCertificato",value);
}
}
}
Please note that after restoring the MapView with the properties value, I had to explicitly restore also the certificateType property with the new value. Otherwise it gets lost.