ItEr20S04ArquitecturaServidorItEr19S04: Fixed casting problem when an Order is not valid.
This commit is contained in:
parent
e08a34793c
commit
8976b8ed42
2 changed files with 15 additions and 7 deletions
|
|
@ -8,7 +8,6 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
|
|
@ -103,7 +102,7 @@ public class MessagesForUser extends GenericForwardComposer implements
|
|||
addMessage(createLabelFor(invalidValue));
|
||||
}
|
||||
|
||||
private Component createLabelFor(InvalidValue invalidValue){
|
||||
public static Label createLabelFor(InvalidValue invalidValue) {
|
||||
Label result = new Label();
|
||||
result.setValue(invalidValue.getPropertyName() + ": "
|
||||
+ invalidValue.getMessage());
|
||||
|
|
|
|||
|
|
@ -76,11 +76,20 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
|
||||
@Override
|
||||
public Component createLabelFor(InvalidValue invalidValue) {
|
||||
Label result= new Label();
|
||||
String orderElementName = ((OrderElement)invalidValue.getBean()).getName();
|
||||
result.setValue(orderElementName+" "+invalidValue.getPropertyName() + ": "
|
||||
+ invalidValue.getMessage());
|
||||
return result;
|
||||
if (invalidValue.getBean() instanceof OrderElement) {
|
||||
Label result = new Label();
|
||||
|
||||
String orderElementName = ((OrderElement) invalidValue
|
||||
.getBean()).getName();
|
||||
|
||||
result.setValue(orderElementName + " "
|
||||
+ invalidValue.getPropertyName() + ": "
|
||||
+ invalidValue.getMessage());
|
||||
return result;
|
||||
} else {
|
||||
return MessagesForUser
|
||||
.createLabelFor(invalidValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue