Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
96eb4e7
TAP5-2810: first pass at Require.js-less modeTAP5-2810: first pass at
thiagohp Jun 24, 2025
9645d2a
TAP5-2810: ES modules for Bootstrap JS
thiagohp Jul 11, 2025
eecdb50
Partial work on ES shims
thiagohp Jul 16, 2025
ead827a
TAP5-2810: More needed support code for Require.js-less mode
thiagohp Jul 26, 2025
95b0b5a
TAP5-2810: fixing ES modules and pageinit relationship
thiagohp Jul 26, 2025
f2894a4
TAP5-2804: Fixing dynamic locale message imports
thiagohp Jul 27, 2025
74120c3
TAP5-2810: fixing ES modules imports with function calls
thiagohp Jul 27, 2025
4f1e2f7
TAP5-2810: fixing ES modules imports with function calls in AJAX request
thiagohp Jul 29, 2025
dd30820
TAP5-2810: enabling tests with Require.js disabled
thiagohp Jul 29, 2025
7fed99b
TAP5-2810: JavaDoc fix.
thiagohp Jul 29, 2025
ff412df
TAP5-2810: fixing import of BeanValidator JS module
thiagohp Jul 29, 2025
10e2bb1
TAP5-2810: fixing syntax error in build.gradle
thiagohp Jul 29, 2025
c468d80
TAP5-2810: fixing another syntax error in build.gradle
thiagohp Jul 29, 2025
7425c43
TAP5-2810: fixing another syntax error in build.gradle again
thiagohp Jul 29, 2025
78e85db
TAP5-2810: DocumentLinkerImpl tests
thiagohp Jul 29, 2025
4d47e17
Fixing AssetTests.external_url_asset_bindings
thiagohp Jul 30, 2025
273babb
TAP5-2810: hopefully final ES module import and init fixes
thiagohp Aug 2, 2025
c7e99e6
Fixing DocumentLinkerImplTest.
thiagohp Aug 2, 2025
89b8fe4
TAP5-2810: adjusting pageinit so it works with AMD and ES
thiagohp Aug 2, 2025
fea0375
TAP5-2810: fixing missing parameter in pageinit call
thiagohp Aug 2, 2025
2bca2d0
TAP5-2810: fixing missing parameter in pageinit call again
thiagohp Aug 2, 2025
b538e77
TAP5-2810: handling lack of module imports better
thiagohp Aug 2, 2025
92e236a
In which we discover HTML is too flexible
thiagohp Aug 3, 2025
58515de
Adapting ExpressionInJsFunction.js to both AMD and ES modules
thiagohp Aug 3, 2025
9fade9e
Fixing AjaxFormLoop in Require.js-less mode
thiagohp Aug 3, 2025
4d8748a
Individual test fixes
thiagohp Aug 3, 2025
c97f8b9
Fixes in DateField, FormFragment, Select, Autocomplete, Zone
thiagohp Aug 4, 2025
b195385
Even more test fixes
thiagohp Aug 6, 2025
7132184
Fixing Tree component tests
thiagohp Aug 7, 2025
71740ab
Removing last @Import(module) from Tapestry components
thiagohp Aug 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions 5_10_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@ Scratch pad for changes destined for the 5.10.0 release notes page.
* `org.apache.tapestry5.services.javascript.ImportPlacement`
* `org.apache.tapestry5.services.javascript.EsModuleConfigurationCallback`
* `org.apache.tapestry5.services.javascript.EsModuleManager`
* `org.apache.tapestry5.services.javascript.ESWrapper`

# Non-backward-compatible changes (but that probably won't cause problems)

# Non-backward-compatible changes

When using Require.js and AMD modules, from Tapestry 5.10.0 on,
the previously returned objects, functions or values are now
the `default` property of the object received from `require()`.
This is a consequence we couldn't avoid from the CoffeeScript
to JavaScript to TypeScript conversion.
* When using Require.js and AMD modules, from Tapestry 5.10.0 on,
the previously returned objects, functions or values are now
the `default` property of the object received from `require()`.
This is a consequence we couldn't avoid from the CoffeeScript
to JavaScript to TypeScript conversion.


# Notes about Require.js disabled mode
* Underscore.js, jQuery and Require.js are not included in the default stack
(i.e. the set of JavaScript files which are included in pages by default).
If you need to use Underscore.js or jQuery, they're automatically available for
import as `underscore` and `jquery`, respectively.


# Overall notes
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,13 @@ task combinedJacocoReport(type:JacocoReport){
}

task continuousIntegration {
// tapestry-javadoc doesn't work with Java 8 anymore. That's why it's only added if != 8.
def dependants = [subprojects.build, // jQuery and Require.js enabled
// 'tapestry-core:testWithJqueryAndRequireJsDisabled',
// 'tapestry-core:testWithPrototypeAndRequireJsEnabled',
def dependants = [
'tapestry-core:testWithPrototypeAndRequireJsDisabled',
'tapestry-core:testWithJqueryAndRequireJsDisabled',
subprojects.build, // jQuery and Require.js enabled
'tapestry-core:testWithPrototypeAndRequireJsEnabled',
combinedJacocoReport]
// tapestry-javadoc doesn't work with Java 8 anymore. That's why it's only added if != 8.
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
dependants << aggregateJavadoc
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
package org.apache.tapestry5.beanvalidator.modules;

import org.apache.tapestry5.MarkupWriter;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.beanvalidator.*;
import org.apache.tapestry5.commons.Configuration;
import org.apache.tapestry5.commons.MappedConfiguration;
import org.apache.tapestry5.commons.OrderedConfiguration;
import org.apache.tapestry5.internal.beanvalidator.*;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Local;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.ioc.services.PropertyShadowBuilder;
import org.apache.tapestry5.ioc.services.ThreadLocale;
import org.apache.tapestry5.services.FieldValidatorDefaultSource;
Expand Down Expand Up @@ -92,14 +94,20 @@ public void configure(jakarta.validation.Configuration<?> configuration)
}

public static void contributeClientConstraintDescriptorSource(final JavaScriptSupport javaScriptSupport,
final Configuration<ClientConstraintDescriptor> configuration)
final Configuration<ClientConstraintDescriptor> configuration,
final @Symbol(SymbolConstants.REQUIRE_JS_ENABLED) boolean requireJsEnabled)
{

final Runnable importJs = requireJsEnabled ?
() -> javaScriptSupport.require(MODULE_NAME) :
() -> javaScriptSupport.importEsModule(MODULE_NAME);

configuration.add(new BaseCCD(Max.class, "value")
{
@Override
public void applyClientValidation(MarkupWriter writer, String message, Map<String, Object> attributes)
{
javaScriptSupport.require("t5/core/validation");
importJs.run();
writer.attributes(
"data-validate", true,
"data-validate-max", attributes.get("value"),
Expand All @@ -113,7 +121,7 @@ public void applyClientValidation(MarkupWriter writer, String message, Map<Strin
@Override
public void applyClientValidation(MarkupWriter writer, String message, Map<String, Object> attributes)
{
javaScriptSupport.require("t5/core/validation");
importJs.run();
writer.attributes(
DataConstants.VALIDATION_ATTRIBUTE, true,
"data-validate-min", attributes.get("value"),
Expand All @@ -127,7 +135,7 @@ public void applyClientValidation(MarkupWriter writer, String message, Map<Strin
@Override
public void applyClientValidation(MarkupWriter writer, String message, Map<String, Object> attributes)
{
javaScriptSupport.require("t5/core/validation");
importJs.run();
writer.attributes(
DataConstants.VALIDATION_ATTRIBUTE, true,
"data-optionality", "required",
Expand All @@ -140,7 +148,7 @@ public void applyClientValidation(MarkupWriter writer, String message, Map<Strin
@Override
public void applyClientValidation(MarkupWriter writer, String message, Map<String, Object> attributes)
{
javaScriptSupport.require(MODULE_NAME);
importJs.run();
writer.attributes(
DataConstants.VALIDATION_ATTRIBUTE, true,
"data-optionality", "prohibited",
Expand All @@ -153,7 +161,7 @@ public void applyClientValidation(MarkupWriter writer, String message, Map<Strin
@Override
public void applyClientValidation(MarkupWriter writer, String message, Map<String, Object> attributes)
{
javaScriptSupport.require(MODULE_NAME);
importJs.run();
writer.attributes(
DataConstants.VALIDATION_ATTRIBUTE, true,
"data-validate-regexp", attributes.get("regexp"),
Expand All @@ -166,7 +174,7 @@ public void applyClientValidation(MarkupWriter writer, String message, Map<Strin
@Override
public void applyClientValidation(MarkupWriter writer, String message, Map<String, Object> attributes)
{
javaScriptSupport.require(MODULE_NAME);
importJs.run();
writer.attributes(
DataConstants.VALIDATION_ATTRIBUTE, true,
"data-range-message", message);
Expand All @@ -192,7 +200,7 @@ public void applyClientValidation(MarkupWriter writer, String message, Map<Strin
@Override
public void applyClientValidation(MarkupWriter writer, String message, Map<String, Object> attributes)
{
javaScriptSupport.require("t5/core/validation");
importJs.run();

writer.attributes(
DataConstants.VALIDATION_ATTRIBUTE, true,
Expand All @@ -206,7 +214,7 @@ public void applyClientValidation(MarkupWriter writer, String message, Map<Strin
@Override
public void applyClientValidation(MarkupWriter writer, String message, Map<String, Object> attributes)
{
javaScriptSupport.require("t5/core/validation");
importJs.run();

writer.attributes(
DataConstants.VALIDATION_ATTRIBUTE, true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.http.Link;
import org.apache.tapestry5.http.services.Request;
import org.apache.tapestry5.internal.services.ajax.RequireJsModeHelper;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

/**
* Base class for link-generating components that are based on a component event request. Such events have an event
Expand Down Expand Up @@ -57,8 +57,8 @@ public abstract class AbstractComponentEventLink extends AbstractLink
@Inject
private Request request;

@Environmental
private JavaScriptSupport javaScriptSupport;
@Inject
private RequireJsModeHelper requireJsModeHelper;

void beginRender(MarkupWriter writer)
{
Expand All @@ -72,7 +72,7 @@ void beginRender(MarkupWriter writer)

if (async)
{
javaScriptSupport.require("t5/core/zone");
requireJsModeHelper.importModule("t5/core/zone");
writer.attributes("data-async-trigger", true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.tapestry5.internal.BeanValidationContext;
import org.apache.tapestry5.internal.InternalComponentResources;
import org.apache.tapestry5.internal.services.FormControlNameManager;
import org.apache.tapestry5.internal.services.ajax.RequireJsModeHelper;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
Expand Down Expand Up @@ -154,6 +155,9 @@ public String toString()

@Environmental
protected JavaScriptSupport javaScriptSupport;

@Inject
private RequireJsModeHelper requireJsModeHelper;

@Environmental
protected ValidationTracker validationTracker;
Expand Down Expand Up @@ -296,7 +300,7 @@ final void afterDecorator()

if (error != null)
{
javaScriptSupport.require("t5/core/fields").invoke("showValidationError").with(assignedClientId, error);
requireJsModeHelper.importModule("t5/core/fields").invoke("showValidationError").with(assignedClientId, error);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.http.Link;
import org.apache.tapestry5.internal.services.RequestConstants;
import org.apache.tapestry5.internal.services.ajax.RequireJsModeHelper;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.ComponentDefaultProvider;
Expand Down Expand Up @@ -62,7 +63,6 @@
*/
@Events(
{EventConstants.ADD_ROW, EventConstants.REMOVE_ROW})
@Import(module = "t5/core/ajaxformloop")
@SupportsInformalParameters
public class AjaxFormLoop
{
Expand Down Expand Up @@ -139,6 +139,9 @@ public class AjaxFormLoop

@Inject
private ComponentResources resources;

@Inject
private RequireJsModeHelper requireJsModeHelper;

@Environmental
private FormSupport formSupport;
Expand Down Expand Up @@ -167,7 +170,7 @@ public class AjaxFormLoop

@Inject
private DeprecationWarning deprecationWarning;

void pageLoaded()
{
deprecationWarning.ignoredComponentParameters(resources, "show");
Expand Down Expand Up @@ -325,6 +328,9 @@ private String toClientValue()

void setupRender(MarkupWriter writer)
{

requireJsModeHelper.importModule("t5/core/ajaxformloop");

pushContext();

iterator = source == null ? Collections.EMPTY_LIST.iterator() : source.iterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.tapestry5.corelib.base.BaseClientElement;
import org.apache.tapestry5.http.Link;
import org.apache.tapestry5.http.services.Request;
import org.apache.tapestry5.internal.services.ajax.RequireJsModeHelper;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.compatibility.DeprecationWarning;
Expand Down Expand Up @@ -63,6 +64,9 @@ public class Alerts extends BaseClientElement

@Inject
private Request request;

@Inject
private RequireJsModeHelper requireJsModeHelper;

void onPageLoaded()
{
Expand Down Expand Up @@ -120,7 +124,7 @@ void addAlertsFromStorage()

for (Alert alert : storage.getAlerts())
{
javaScriptSupport.require("t5/core/alert").with(alert.toJSON());
requireJsModeHelper.importModule("t5/core/alert").with(alert.toJSON());
}

storage.dismissNonPersistent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.tapestry5.commons.Messages;
import org.apache.tapestry5.corelib.base.AbstractField;
import org.apache.tapestry5.dom.Element;
import org.apache.tapestry5.internal.services.ajax.RequireJsModeHelper;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
Expand Down Expand Up @@ -49,8 +50,7 @@
* @see TextField
*/
// TODO: More testing; see https://issues.apache.org/jira/browse/TAPESTRY-1844
@Import(stylesheet = "${tapestry.datepicker}/css/datepicker.css",
module = "t5/core/datefield")
@Import(stylesheet = "${tapestry.datepicker}/css/datepicker.css")
@Events(EventConstants.VALIDATE)
public class DateField extends AbstractField
{
Expand Down Expand Up @@ -127,6 +127,9 @@ public class DateField extends AbstractField

@Inject
private DeprecationWarning deprecationWarning;

@Inject
private RequireJsModeHelper requireJsModeHelper;

@Inject
@Symbol(SymbolConstants.LENIENT_DATE_FORMAT)
Expand Down Expand Up @@ -225,6 +228,9 @@ JSONObject onFormat(@RequestParameter(INPUT_PARAMETER)

void beginRender(MarkupWriter writer)
{

requireJsModeHelper.importModule("t5/core/datefield");

String value = validationTracker.getInput(this);

if (value == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.alerts.AlertManager;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.Environmental;
Expand Down Expand Up @@ -94,6 +95,10 @@ public class DevTool

@Inject
private ReloadHelper reloadHelper;

@Inject
@Symbol(SymbolConstants.REQUIRE_JS_ENABLED)
private boolean requireJsEnabled;

public String getZoneElement()
{
Expand Down Expand Up @@ -122,7 +127,14 @@ boolean beginRender()
{
if (enabled)
{
javaScriptSupport.importStack("core").require("bootstrap/dropdown");
if (requireJsEnabled)
{
javaScriptSupport.importStack("core").require("bootstrap/dropdown");
}
else
{
javaScriptSupport.importEsModule("bootstrap/dropdown");
}
}

return enabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.commons.util.CollectionFactory;
import org.apache.tapestry5.internal.services.ajax.RequireJsModeHelper;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.services.ComponentOverride;
Expand Down Expand Up @@ -79,7 +80,7 @@ public class Errors
private String closeButtonCssClass;

@Inject
private JavaScriptSupport javaScriptSupport;
private RequireJsModeHelper requireJsModeHelper;

boolean beginRender(MarkupWriter writer)
{
Expand Down Expand Up @@ -146,7 +147,7 @@ boolean beginRender(MarkupWriter writer)
* @see ComponentOverride
*/
protected void setUpJavaScript() {
javaScriptSupport.require("bootstrap/alert");
requireJsModeHelper.importModule("bootstrap/alert");
}

}
Loading