本文整理匯總了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);
}