1

是否可以在 Jelly 中动态更新文本框的值?

我有一个下拉框,其选项是根据表单中的先前数据确定的。使用在线提供的文档很简单(只需使用doFill...Items()描述符中的方法)。每个选项代表一个"Property". 在下拉菜单下,我有一个文本框,它代表属性的"Property Value".

果冻档案:

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
    <f:entry title="Property" field="property">
        <f:select />
    </f:entry>
    <f:entry title="Value" field="propertyValue">
        <f:textbox value="${descriptor.getDefaultValue()}" />
    </f:entry>
    <div align="right">
        <f:repeatableDeleteButton/>
    </div>
</j:jelly>

每次选择下拉框中的新项目时,我想用属性的当前值更新文本框。我一直在尝试一些不同的事情,例如在 Jelly 文件中设置defaultvalue属性。但是,我还没有找到在表单初始化后触发文本框更新的方法。

描述符:

@Extension
public static class DescriptorImpl extends Descriptor<ProvisionPropertyParam> {
    /**
     * Gets a list of update properties for a specific component.
     *
     * @param component
     * @return ListBoxModel - the list of update properties for the component
     */
    public ListBoxModel doFillPropertyItems(@QueryParameter("component") @RelativePath("..") String component) {
        return ServiceManager.userInterfaceService().getProvisionProperties(component);
    }
    public String doFillPropertyValue(@QueryParameter("property") String property) {
        return ServiceManager.userInterfaceService().getPropertyValue(property);
    }
    public String getDefaultValue() {
        return "Test";
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public String getDisplayName() {
        return "Provision property";
    }
}

我能够使用该getDefaultValue()方法成功设置文本框的值。但是,我需要能够使用doFillPropertyValue(), 或一些以相同方式操作的不同命名的方法。我想它应该像在果冻文件中设置方法一样简单,但是有问题的方法有一个参数,考虑到我没有要发送的值,我不确定如何在果冻中调用方法它。

我尝试设置:

<f:textbox value="${descriptor.doFillPropertyValue()}"/>

但它显然没有做任何事情。谁能给我一些指导?

4

2 回答 2

0

在我的果冻代码中,我使用这样的东西:

    <j:forEach var="currentDescriptor" items="${descriptor.tilogiPlateformeDescriptors}" varStatus="loop">

在我的java代码中,方法是:

    public DescriptorExtensionList<TilogiPlateforme, TilogiPlateformeDescriptor> getTilogiPlateformeDescriptors()
于 2015-06-12T14:57:58.080 回答
0

doFill{Variable}Items刷新页面或使用配置选项进入页面时调用方法。所以它的静态方法为页面调用了一次。

Jelly Pages 支持 HTML 和 Javascript。对于下拉框,您可以使用onfocusonclick方法 as onfocus = "populateTextbox()"

使用简单的 java 脚本作为

select = document.getElementById("Id of DropDown");
selectedData = select.options.selected.text

selectedData用值更新文本框

于 2018-09-28T04:52:01.987 回答