当前位置: 首页>>代码示例>>Java>>正文


Java KRADUtils.translateToMapSafeKey方法代码示例

本文整理汇总了Java中org.kuali.rice.krad.util.KRADUtils.translateToMapSafeKey方法的典型用法代码示例。如果您正苦于以下问题:Java KRADUtils.translateToMapSafeKey方法的具体用法?Java KRADUtils.translateToMapSafeKey怎么用?Java KRADUtils.translateToMapSafeKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kuali.rice.krad.util.KRADUtils的用法示例。


在下文中一共展示了KRADUtils.translateToMapSafeKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareSelectFieldForLine

import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
public static void prepareSelectFieldForLine(Field selectField, CollectionGroup collectionGroup, String lineBindingPath,
        Object line) {
    // if select property name set use as property name for select field
    String selectPropertyName = collectionGroup.getLineSelectPropertyName();
    if (StringUtils.isNotBlank(selectPropertyName)) {
        // if select property contains form prefix, will bind to form and not each line
        if (selectPropertyName.startsWith(UifConstants.NO_BIND_ADJUST_PREFIX)) {
            selectPropertyName = StringUtils.removeStart(selectPropertyName, UifConstants.NO_BIND_ADJUST_PREFIX);
            ((DataBinding) selectField).getBindingInfo().setBindingName(selectPropertyName);
            ((DataBinding) selectField).getBindingInfo().setBindToForm(true);
        } else {
            ((DataBinding) selectField).getBindingInfo().setBindingName(selectPropertyName);
            ((DataBinding) selectField).getBindingInfo().setBindByNamePrefix(lineBindingPath);
        }
    } else {
        // select property name not given, use UifFormBase#selectedCollectionLines
        String collectionLineKey = KRADUtils.translateToMapSafeKey(
                collectionGroup.getBindingInfo().getBindingPath());
        String selectBindingPath = UifPropertyPaths.SELECTED_COLLECTION_LINES + "['" + collectionLineKey + "']";

        ((DataBinding) selectField).getBindingInfo().setBindingName(selectBindingPath);
        ((DataBinding) selectField).getBindingInfo().setBindToForm(true);
    }

    setControlValueToLineIdentifier(selectField, line, lineBindingPath);
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:CollectionLayoutUtils.java

示例2: initializeNewCollectionLine

import org.kuali.rice.krad.util.KRADUtils; //导入方法依赖的package包/类
/**
 * Initializes a new instance of the collection data object class for the add line.
 *
 * <p>If the add line property was not specified for the collection group the new lines will be
 * added to the generic map on the {@code UifFormBase}, else it will be added to the property given by
 * the addLineBindingInfo</p>
 *
 * <p>New line will only be created if the current line property is null or clearExistingLine is true.
 * In the case of a new line default values are also applied</p>
 */
public void initializeNewCollectionLine(View view, Object model, CollectionGroup collectionGroup,
        boolean clearExistingLine) {
    Object newLine = null;

    // determine if we are binding to generic form map or a custom property
    if (StringUtils.isBlank(collectionGroup.getAddLinePropertyName())) {
        // bind to form map
        if (!(model instanceof UifFormBase)) {
            throw new RuntimeException(
                    "Cannot create new collection line for group: " + collectionGroup.getPropertyName()
                            + ". Model does not extend " + UifFormBase.class.getName()
            );
        }

        // get new collection line map from form
        Map<String, Object> newCollectionLines = ObjectPropertyUtils.getPropertyValue(model,
                UifPropertyPaths.NEW_COLLECTION_LINES);
        if (newCollectionLines == null) {
            newCollectionLines = new HashMap<String, Object>();
            ObjectPropertyUtils.setPropertyValue(model, UifPropertyPaths.NEW_COLLECTION_LINES, newCollectionLines);
        }

        // set binding path for add line
        String newCollectionLineKey = KRADUtils.translateToMapSafeKey(
                collectionGroup.getBindingInfo().getBindingPath());
        String addLineBindingPath = UifPropertyPaths.NEW_COLLECTION_LINES + "['" + newCollectionLineKey + "']";
        collectionGroup.getAddLineBindingInfo().setBindingPath(addLineBindingPath);

        // if there is not an instance available or we need to clear create a new instance
        if (!newCollectionLines.containsKey(newCollectionLineKey) || (newCollectionLines.get(newCollectionLineKey)
                == null) || clearExistingLine) {
            // create new instance of the collection type for the add line
            newLine = KRADUtils.createNewObjectFromClass(collectionGroup.getCollectionObjectClass());
            newCollectionLines.put(newCollectionLineKey, newLine);
        }
    } else {
        // bind to custom property
        Object addLine = ObjectPropertyUtils.getPropertyValue(model,
                collectionGroup.getAddLineBindingInfo().getBindingPath());
        if ((addLine == null) || clearExistingLine) {
            newLine = KRADUtils.createNewObjectFromClass(collectionGroup.getCollectionObjectClass());
            ObjectPropertyUtils.setPropertyValue(model, collectionGroup.getAddLineBindingInfo().getBindingPath(),
                    newLine);
        }
    }

    // apply default values if a new line was created
    if (newLine != null) {
        ViewLifecycle.getHelper().applyDefaultValuesForCollectionLine(collectionGroup, newLine);
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:62,代码来源:CollectionGroupBuilder.java


注:本文中的org.kuali.rice.krad.util.KRADUtils.translateToMapSafeKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。