-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Validation issue
PostPosted: Mon Jul 21, 2008 3:34 pm 
Newbie

Joined: Mon Jul 21, 2008 3:15 pm
Posts: 7
Hi, I've the current problem.

This is the entity I'm working on.


[code]
public class InventoryOrder extends BasicEntity {

private Date date;

private DepartmentGroup departmentGroup;

[b]
@InventoryOrderDepartment
private Department department;
[/b]

private Boolean partialInventory;

private Boolean detailedInventory;

private Kind kind;

private Group group;

private Set<Center> centers;

private Date preliminarBalanceDeadLine;

private Date finalBalanceDeadLine;

private Integer daysBeforeStartWarning = 1;

private String mailWarningStartLegend;

private String mailPreliminarBreachLegend;

private String mailFinalBreachLegend;

private Set<InventoryOrderCenter> centersOrders;
}
[/code]

This is the validator I've made.



[code]

@Documented
@ValidatorClass(InventoryOrderDepartmentValidator.class)
@Target({METHOD, FIELD})
@Retention(RUNTIME)

public @interface InventoryOrderDepartment {
String message() default "{InventoryOrder.Validator.Department}";
}


public class InventoryOrderDepartmentValidator implements Validator<InventoryOrderDepartment>, Serializable {

private static final long serialVersionUID = 1L;

public void initialize(InventoryOrderDepartment parameters) {

}

public boolean isValid(Object value){
...
}
}
[/code]


The problem:

During the [code]isValid[/code] method execution I need data from [code]InventoryOrder[/code] besides the [code]department[/code] attribute.

To be more specific, I need to validate if the [code]department[/code] that is to be set is not already persisted in the DB with the same [code]date[/code].

Is there anyway to specified the value of the entity that is gonna be validate, without, this, being necesary the attribute itself?

If not... how could I make this validation posible?

Thanx in advance


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.