protected void addHiddenFieldsForInputAndFilterData(InputAndFilterData aInputAndFilterData) { if ((aInputAndFilterData != null) && (aInputAndFilterData.getInputHiddenFieldNameValueMap() != null)) { ObjectFactory tempObjectFactory = new ObjectFactory(); for (Map.Entry<String, String> tempMapEntry : aInputAndFilterData.getInputHiddenFieldNameValueMap().entrySet()) { String tempName = tempMapEntry.getKey(); Object tempValue = tempMapEntry.getValue(); ParameterT parameter = tempObjectFactory.createStringT(); parameter.setName(tempName); parameter.setUse(UseT.OPTIONAL); // compile list of parameters (TODO: is this needed?) getParameterMap().put(parameter.getName(), parameter); HiddenFieldT hiddenField = new HiddenFieldT(); hiddenField.setInitValue(tempValue.toString()); hiddenField.setParameterRef(tempName); Atdl4jWidget hiddenFieldWidget = getAtdl4jWidgetFactory().createHiddenFieldT(hiddenField, parameter); hiddenFieldWidget.setHiddenFieldForInputAndFilterData(true); addToAtdl4jWidgetMap(tempName, hiddenFieldWidget); addToAtdl4jWidgetWithParameterMap(tempName, hiddenFieldWidget); } } }
public Atdl4jWidget getAtdl4jWidgetForParameter(ParameterT aParameterRef) { if ((aParameterRef != null) && (getAtdl4jWidgetWithParameterMap() != null)) { Collection<Atdl4jWidget<?>> tempAtdl4jWidgetWithParameterMapValues = (Collection<Atdl4jWidget<?>>) getAtdl4jWidgetWithParameterMap().values(); for (Atdl4jWidget<?> widget : tempAtdl4jWidgetWithParameterMapValues) { if (aParameterRef.equals(widget.getParameter())) { return widget; } } } return null; }
/** * @param strategy * @return */ protected Map<String, ParameterT> buildParameters(StrategyT strategy) { Map<String, ParameterT> tempParameters = new HashMap<String, ParameterT>(); // build parameters for (ParameterT parameter : strategy.getParameter()) { // compile list of parameters (TODO: is this needed?) tempParameters.put(parameter.getName(), parameter); boolean tempIsRequired = false; // required fields should be validated as well if (parameter.getUse() != null) { if (parameter.getUse().equals(UseT.REQUIRED)) { tempIsRequired = true; ValidationRule requiredFieldRule = new ValueOperatorValidationRule(parameter.getName(), OperatorT.EX, null, strategy); getStrategyRuleset().addRequiredFieldRule(requiredFieldRule); } } ParameterTypeConverter tempTypeConverter = TypeConverterFactoryConfig.getTypeConverterFactory() .createParameterTypeConverter(parameter); if (ParameterHelper.getConstValue(parameter) != null) { String tempStringValue = tempTypeConverter.convertParameterValueToComparisonString( ParameterHelper.getConstValue(parameter)); ValidationRule tempFieldRule = new ValueOperatorValidationRule( parameter.getName(), OperatorT.EQ, tempStringValue, strategy); if (tempIsRequired) { getStrategyRuleset().addConstFieldRule(tempFieldRule); } else // Parameter is optional { LogicalOperatorValidationRule tempOptionalWrapperEdit = new LogicalOperatorValidationRule(LogicOperatorT.OR, strategy); tempOptionalWrapperEdit.addRule( new ValueOperatorValidationRule(parameter.getName(), OperatorT.NX, null, strategy)); tempOptionalWrapperEdit.addRule(tempFieldRule); getStrategyRuleset().addConstFieldRule(tempOptionalWrapperEdit); } } if (ParameterHelper.getMinValue(parameter) != null) { String tempStringValue = tempTypeConverter.convertParameterValueToComparisonString( ParameterHelper.getMinValue(parameter)); ValidationRule tempFieldRule = new ValueOperatorValidationRule( parameter.getName(), OperatorT.GE, tempStringValue, strategy); if (tempIsRequired) { getStrategyRuleset().addRangeFieldRule(tempFieldRule); } else // Parameter is optional { LogicalOperatorValidationRule tempOptionalWrapperEdit = new LogicalOperatorValidationRule(LogicOperatorT.OR, strategy); tempOptionalWrapperEdit.addRule( new ValueOperatorValidationRule(parameter.getName(), OperatorT.NX, null, strategy)); tempOptionalWrapperEdit.addRule(tempFieldRule); getStrategyRuleset().addRangeFieldRule(tempOptionalWrapperEdit); } } if (ParameterHelper.getMaxValue(parameter) != null) { String tempStringValue = tempTypeConverter.convertParameterValueToComparisonString( ParameterHelper.getMaxValue(parameter)); ValidationRule tempFieldRule = new ValueOperatorValidationRule( parameter.getName(), OperatorT.LE, tempStringValue, strategy); if (tempIsRequired) { getStrategyRuleset().addRangeFieldRule(tempFieldRule); } else // Parameter is optional { LogicalOperatorValidationRule tempOptionalWrapperEdit = new LogicalOperatorValidationRule(LogicOperatorT.OR, strategy); tempOptionalWrapperEdit.addRule( new ValueOperatorValidationRule(parameter.getName(), OperatorT.NX, null, strategy)); tempOptionalWrapperEdit.addRule(tempFieldRule); getStrategyRuleset().addRangeFieldRule(tempOptionalWrapperEdit); } } if (ParameterHelper.getMinLength(parameter) != null) { ValidationRule tempFieldRule = new LengthValidationRule( parameter.getName(), OperatorT.GE, ParameterHelper.getMinLength(parameter), strategy); if (tempIsRequired) { getStrategyRuleset().addLengthFieldRule(tempFieldRule); } else // Parameter is optional { LogicalOperatorValidationRule tempOptionalWrapperEdit = new LogicalOperatorValidationRule(LogicOperatorT.OR, strategy); tempOptionalWrapperEdit.addRule( new ValueOperatorValidationRule(parameter.getName(), OperatorT.NX, null, strategy)); tempOptionalWrapperEdit.addRule(tempFieldRule); getStrategyRuleset().addLengthFieldRule(tempOptionalWrapperEdit); } } if (ParameterHelper.getMaxLength(parameter) != null) { ValidationRule tempFieldRule = new LengthValidationRule( parameter.getName(), OperatorT.LE, ParameterHelper.getMaxLength(parameter), strategy); if (tempIsRequired) { getStrategyRuleset().addLengthFieldRule(tempFieldRule); } else // Parameter is optional { LogicalOperatorValidationRule tempOptionalWrapperEdit = new LogicalOperatorValidationRule(LogicOperatorT.OR, strategy); tempOptionalWrapperEdit.addRule( new ValueOperatorValidationRule(parameter.getName(), OperatorT.NX, null, strategy)); tempOptionalWrapperEdit.addRule(tempFieldRule); getStrategyRuleset().addLengthFieldRule(tempOptionalWrapperEdit); } } // validate types based on patterns if (parameter instanceof MultipleCharValueT) { MultipleCharValueT multipleCharValueT = (MultipleCharValueT) parameter; ValidationRule patternBasedRule = new PatternValidationRule(multipleCharValueT.getName(), "\\S?(\\s\\S?)*"); getStrategyRuleset().addPatternRule(patternBasedRule); } else if (parameter instanceof MultipleStringValueT) { MultipleStringValueT multipleStringValueT = (MultipleStringValueT) parameter; ValidationRule patternBasedRule = new PatternValidationRule(multipleStringValueT.getName(), "\\S+(\\s\\S+)*"); getStrategyRuleset().addPatternRule(patternBasedRule); } // 2/1/2010 John Shields added // TODO Deprecate trueWireValue and falseWireValue attribute; if (parameter instanceof BooleanT) { if (((BooleanT) parameter).getTrueWireValue() != null) throw new IllegalStateException( "Attribute \"trueWireValue\" on Boolean_t is deprecated." + " Please use \"checkedEnumRef\" on CheckBox_t or RadioButton_t instead."); if (((BooleanT) parameter).getFalseWireValue() != null) throw new IllegalStateException( "Attribute \"falseWireValue\" on Boolean_t is deprecated." + " Please use \"uncheckedEnumRef\" on CheckBox_t or RadioButton_t instead."); } } return tempParameters; }