如何在Tapestry webapp中设置t5 / core / datefield的默认配置

时间:2017-02-06 22:59:03

标签: tapestry

我发现最新的Tapestry5-jquery 4.1.2在其Module类中覆盖了核心datefield。

@Contribute(ModuleManager.class)
    public static void setupComponentsShims(
            MappedConfiguration<String, Object> configuration,
            @Inject @Path("/META-INF/modules/tjq/datefield.js") Resource datefield,
            @Inject @Path("${jquery.assets.root}/vendor/jquery.mousewheel.js") Resource jquerymousewheel,
            @Symbol(JQuerySymbolConstants.ADD_MOUSEWHEEL_EVENT) boolean mouseWheelIncluded) {

        **configuration.add("t5/core/datefield",
        new JavaScriptModuleConfiguration(datefield));**

        if (mouseWheelIncluded)
            configuration.add("vendor/jquerymousewheel",
                    new JavaScriptModuleConfiguration(jquerymousewheel)
                            .dependsOn("jquery"));
    }

我仍然想使用tapestry核心的默认版本。 如何在我的web-app中将其设置回使用Tapestry5-jquery库?现在我确实修改了Tapestry-jquery lib代码,但应该更简单,而不是修改外部lib代码。

感谢。

1 个答案:

答案 0 :(得分:2)

您可以看到JQueryModule中的覆盖是使用mapped configuration ModuleManager服务完成的。

与其他贡献一样,您可以使用configuration.override(...)覆盖此内容,即:

@Contribute(ModuleManager.class)
public void useCoreDateField(
        MappedConfiguration<String, Object> configuration,
        AssetSource assetSource)
{
    // Load core javascript for the component
    Resource dateField = assetSource.resourceForPath(
        "/META-INF/modules/t5/core/datefield.js");

    // Override the contribution
    configuration.override("t5/core/datefield",
        new JavaScriptModuleConfiguration(dateField));
}

执行此操作后,请不要忘记清除浏览器缓存。

相关问题