本文整理汇总了Java中org.kuali.rice.krad.uif.util.ConstraintStateUtils.getClientViewValidationState方法的典型用法代码示例。如果您正苦于以下问题:Java ConstraintStateUtils.getClientViewValidationState方法的具体用法?Java ConstraintStateUtils.getClientViewValidationState怎么用?Java ConstraintStateUtils.getClientViewValidationState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kuali.rice.krad.uif.util.ConstraintStateUtils
的用法示例。
在下文中一共展示了ConstraintStateUtils.getClientViewValidationState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCustomClientsideUtilMethod
import org.kuali.rice.krad.uif.util.ConstraintStateUtils; //导入方法依赖的package包/类
/**
* Test for getClientViewValidationState method that returns the state the client should validate for
*/
@Test
public void testCustomClientsideUtilMethod() {
View view = new FormView();
StateMapping genericStateMapping = new StateMappingBase();
List<String> states = new ArrayList<String>();
states.add("state1");
states.add("state2");
states.add("state3");
states.add("state4");
states.add("state5");
states.add("state6");
states.add("state7");
states.add("state8");
genericStateMapping.setStates(states);
genericStateMapping.setStatePropertyName("state");
UifFormBase model = new UifFormBase();
Map<String, String> customClientStateMap = new HashMap<String, String>();
customClientStateMap.put("state1", "state3");
customClientStateMap.put("state4", "state8");
customClientStateMap.put("state7", "state7");
genericStateMapping.setCustomClientSideValidationStates(customClientStateMap);
view.setStateMapping(genericStateMapping);
//custom
model.setState("state1");
String state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state3", state);
model.setState("state4");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state8", state);
model.setState("state7");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state7", state);
//should return next state
model.setState("state2");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state3", state);
model.setState("state3");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state4", state);
model.setState("state5");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state6", state);
//should return state8 (no next state)
model.setState("state8");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state8", state);
//should back same state sent in - bad or no configurations, if then used for get applicableConstraint
//will get back the appropriate constraint
model.setState("fake");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("fake", state);
model.setState(null);
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertNull(state);
model.setState("");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("", state);
model.setState("state1");
StateMapping emptyStateMapping = new StateMappingBase();
emptyStateMapping.setStatePropertyName("state");
view.setStateMapping(emptyStateMapping);
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state1", state);
//return back null state when StateMapping is not configured
view.setStateMapping(null);
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertNull(state);
}
示例2: testCustomClientsideUtilMethod
import org.kuali.rice.krad.uif.util.ConstraintStateUtils; //导入方法依赖的package包/类
/**
* Test for getClientViewValidationState method that returns the state the client should validate for
*/
@Test
public void testCustomClientsideUtilMethod() {
View view = new View();
StateMapping genericStateMapping = new StateMappingBase();
List<String> states = new ArrayList<String>();
states.add("state1");
states.add("state2");
states.add("state3");
states.add("state4");
states.add("state5");
states.add("state6");
states.add("state7");
states.add("state8");
genericStateMapping.setStates(states);
genericStateMapping.setStatePropertyName("state");
UifFormBase model = new UifFormBase();
Map<String, String> customClientStateMap = new HashMap<String, String>();
customClientStateMap.put("state1", "state3");
customClientStateMap.put("state4", "state8");
customClientStateMap.put("state7", "state7");
genericStateMapping.setCustomClientSideValidationStates(customClientStateMap);
view.setStateMapping(genericStateMapping);
//custom
model.setState("state1");
String state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state3", state);
model.setState("state4");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state8", state);
model.setState("state7");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state7", state);
//should return next state
model.setState("state2");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state3", state);
model.setState("state3");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state4", state);
model.setState("state5");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state6", state);
//should return state8 (no next state)
model.setState("state8");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state8", state);
//should back same state sent in - bad or no configurations, if then used for get applicableConstraint
//will get back the appropriate constraint
model.setState("fake");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("fake", state);
model.setState(null);
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertNull(state);
model.setState("");
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("", state);
model.setState("state1");
StateMapping emptyStateMapping = new StateMappingBase();
emptyStateMapping.setStatePropertyName("state");
view.setStateMapping(emptyStateMapping);
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertEquals("state1", state);
//return back null state when StateMapping is not configured
view.setStateMapping(null);
state = ConstraintStateUtils.getClientViewValidationState(model, view);
Assert.assertNull(state);
}