[jira] [Commented] (TAP5-2764) JSONArray improvements
[ https://issues.apache.org/jira/browse/TAP5-2764?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17772981#comment-17772981 ] ASF subversion and git services commented on TAP5-2764: --- Commit 0da3aaa27e404c7d3dc85898cfaa79180241b9aa in tapestry-5's branch refs/heads/TAP5-2764 from Ben Weidig [ https://gitbox.apache.org/repos/asf?p=tapestry-5.git;h=0da3aaa27 ] TAP5-2764: static JSONArray#empty() added > JSONArray improvements > -- > > Key: TAP5-2764 > URL: https://issues.apache.org/jira/browse/TAP5-2764 > Project: Tapestry 5 > Issue Type: Improvement > Components: tapestry-json >Reporter: Ben Weidig >Assignee: Ben Weidig >Priority: Minor > > The following improvements should be added to JSONArray: > *Implement {{List}}* > Right now, the type implements {{Collection}} but it could bei a > {{List}} instead. > As it's a thin wrapper arround {{ArrayList}} anyway, using a more > feature-packed interface makes sense, as there's almost no additional cost to > it. > *Fix {{Object remove(int)}} contract* > Index-based removal is a {{{}List{}}}-related method with a certain contract, > like throwing an Exception on invalid index arguments. > Event hough it _should be_ expected behavior on any {{{}List{}}}-like data > structures, it's going to be a breaking change here. > *Add {{static JSONArray empty()}}* > Similar to {{{}Collections.emptyList(){}}}, a convenience method for creating > an empty and immutable instance should be added to reduce object creation / > memory requirements, as an {{ArrayList}} will always needs some memory, even > if empty. > Implementation-wise, it would require a new (private) constructor that allows > setting the underlying data structure. > Then, {{empty()}} could simply use {{{}Collections.emptyList(){}}}. > {color:#FF}As the changes contain a breaking change, it should be > released in a minor-release, not patch.{color} > Related mailing list thread: > [https://lists.apache.org/thread/pf7hwy2tp5x7ktbzq9w2btwdd1xkyod2] -- This message was sent by Atlassian Jira (v8.20.10#820010)
[tapestry-5] 01/01: TAP5-2764: static JSONArray#empty() added
This is an automated email from the ASF dual-hosted git repository. benw pushed a commit to branch TAP5-2764 in repository https://gitbox.apache.org/repos/asf/tapestry-5.git commit 0da3aaa27e404c7d3dc85898cfaa79180241b9aa Author: Ben Weidig AuthorDate: Sun Oct 8 15:13:45 2023 +0200 TAP5-2764: static JSONArray#empty() added --- .../java/org/apache/tapestry5/json/JSONArray.java | 23 +- .../test/groovy/json/specs/JSONArraySpec.groovy| 20 +++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/tapestry-json/src/main/java/org/apache/tapestry5/json/JSONArray.java b/tapestry-json/src/main/java/org/apache/tapestry5/json/JSONArray.java index ee9e755b9..02cacfb17 100644 --- a/tapestry-json/src/main/java/org/apache/tapestry5/json/JSONArray.java +++ b/tapestry-json/src/main/java/org/apache/tapestry5/json/JSONArray.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Objects; import org.apache.tapestry5.json.exceptions.JSONArrayIndexOutOfBoundsException; import org.apache.tapestry5.json.exceptions.JSONSyntaxException; @@ -53,11 +54,31 @@ public final class JSONArray extends JSONCollection implements Collection values; +private static final JSONArray EMPTY = new JSONArray(Collections.emptyList()); + +/** + * Returns an immutable {@code JSONArray}. + */ +public static final JSONArray empty() { +return EMPTY; +} + /** * Creates a {@code JSONArray} with no values. */ public JSONArray() { -values = new ArrayList(); +this(new ArrayList<>()); +} + +/** + * Creates a {@code JSONArray} with a specific underlying data structure. + * + * @param list the desired underlying {@code List} to be used. + * @throws NullPointerException if the list is null. + */ +private JSONArray(List list) { +Objects.requireNonNull(list); +values = list; } /** diff --git a/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy b/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy index 35b76584a..df8e2db7a 100644 --- a/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy +++ b/tapestry-json/src/test/groovy/json/specs/JSONArraySpec.groovy @@ -617,4 +617,24 @@ class JSONArraySpec extends Specification { Double.NaN ] } + +def "empty() returns an empty JSONArray"() { + +when: +def array = JSONArray.empty() + +then: + +array.isEmpty() +} + +def "empty() retuns an immutable JSONArray"() { +def array = JSONArray.empty() + +when: +array.add("") + +then: +UnsupportedOperationException e = thrown() +} }
[tapestry-5] branch TAP5-2764 created (now 0da3aaa27)
This is an automated email from the ASF dual-hosted git repository. benw pushed a change to branch TAP5-2764 in repository https://gitbox.apache.org/repos/asf/tapestry-5.git at 0da3aaa27 TAP5-2764: static JSONArray#empty() added This branch includes the following new commits: new 0da3aaa27 TAP5-2764: static JSONArray#empty() added The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
[jira] [Assigned] (TAP5-2764) JSONArray improvements
[ https://issues.apache.org/jira/browse/TAP5-2764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Ben Weidig reassigned TAP5-2764: Assignee: Ben Weidig > JSONArray improvements > -- > > Key: TAP5-2764 > URL: https://issues.apache.org/jira/browse/TAP5-2764 > Project: Tapestry 5 > Issue Type: Improvement > Components: tapestry-json >Reporter: Ben Weidig >Assignee: Ben Weidig >Priority: Minor > > The following improvements should be added to JSONArray: > *Implement {{List}}* > Right now, the type implements {{Collection}} but it could bei a > {{List}} instead. > As it's a thin wrapper arround {{ArrayList}} anyway, using a more > feature-packed interface makes sense, as there's almost no additional cost to > it. > *Fix {{Object remove(int)}} contract* > Index-based removal is a {{{}List{}}}-related method with a certain contract, > like throwing an Exception on invalid index arguments. > Event hough it _should be_ expected behavior on any {{{}List{}}}-like data > structures, it's going to be a breaking change here. > *Add {{static JSONArray empty()}}* > Similar to {{{}Collections.emptyList(){}}}, a convenience method for creating > an empty and immutable instance should be added to reduce object creation / > memory requirements, as an {{ArrayList}} will always needs some memory, even > if empty. > Implementation-wise, it would require a new (private) constructor that allows > setting the underlying data structure. > Then, {{empty()}} could simply use {{{}Collections.emptyList(){}}}. > {color:#FF}As the changes contain a breaking change, it should be > released in a minor-release, not patch.{color} > Related mailing list thread: > [https://lists.apache.org/thread/pf7hwy2tp5x7ktbzq9w2btwdd1xkyod2] -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (TAP5-2764) JSONArray improvements
Ben Weidig created TAP5-2764: Summary: JSONArray improvements Key: TAP5-2764 URL: https://issues.apache.org/jira/browse/TAP5-2764 Project: Tapestry 5 Issue Type: Improvement Components: tapestry-json Reporter: Ben Weidig The following improvements should be added to JSONArray: *Implement {{List}}* Right now, the type implements {{Collection}} but it could bei a {{List}} instead. As it's a thin wrapper arround {{ArrayList}} anyway, using a more feature-packed interface makes sense, as there's almost no additional cost to it. *Fix {{Object remove(int)}} contract* Index-based removal is a {{{}List{}}}-related method with a certain contract, like throwing an Exception on invalid index arguments. Event hough it _should be_ expected behavior on any {{{}List{}}}-like data structures, it's going to be a breaking change here. *Add {{static JSONArray empty()}}* Similar to {{{}Collections.emptyList(){}}}, a convenience method for creating an empty and immutable instance should be added to reduce object creation / memory requirements, as an {{ArrayList}} will always needs some memory, even if empty. Implementation-wise, it would require a new (private) constructor that allows setting the underlying data structure. Then, {{empty()}} could simply use {{{}Collections.emptyList(){}}}. {color:#FF}As the changes contain a breaking change, it should be released in a minor-release, not patch.{color} Related mailing list thread: [https://lists.apache.org/thread/pf7hwy2tp5x7ktbzq9w2btwdd1xkyod2] -- This message was sent by Atlassian Jira (v8.20.10#820010)
svn commit: r1084348 [2/2] - in /websites/production/tapestry/content: ./ cache/
Modified: websites/production/tapestry/content/release-notes-53.html == --- websites/production/tapestry/content/release-notes-53.html (original) +++ websites/production/tapestry/content/release-notes-53.html Sun Oct 8 10:12:16 2023 @@ -143,11 +143,11 @@ This is the consolidated list of changes between Tapestry versions 5.2 and 5.3. To upgrade from 5.2 to 5.3, most users who are not using deprecated features will be able to just update the Maven dependency in their POM file (or download the new JAR file) and the new version will just work. However, please read carefully below before upgrading, and also review theHow to Upgrade instructions.Contents/**/ +/*]]>*/ Breaking ChangesNew FeaturesSub-tasks CompletedBugs FixedImprovements MadeNew Features ImplementedTasks Completed Breaking ChangesTapestry now depends on Servlet API version 2.5 (prior releases worked with 2.4).Tapestry no longer supports the ability to inject the component id into a String field. This was rarely (if ever) used functionality that caused unwanted conflicts elsewhere. When a component needs to know its component id, it may inject the http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/ComponentResources.html;>ComponentResources object, and invoke getCompleteId().Tapestry templates without a !DOCTYPE are treated a bit differently in Tapestry 5.3; they are treated as if they have the HTML5 doctype (!DOCTYPE html). See further notes about component templates.Many classes and interfaces that were deprecated in prior releases of Tapestry have been removed in Tapestry 5.3. See https://issues.apache.org/jira/browse/TAP5-1432;>the full list. As always, you should use your IDE to find and replace all deprecated items before you upgrade. The following are the most significant of these:@IncludeJavaScriptLibrary and @IncludeStylesheet annotations (replaced by @http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/annotations/Import.html;>Import)@ApplicationState annotation (replaced with @http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/annotations/SessionState.html;>SessionState)"validateForm" event triggered by Form component (replaced with "validate" event)Code and constants related to page poolingIn addition, some of the abstract base classes used with the tapestry-func library have changed into interfaces; you will want to recompile, but may also need to adjust your code, depending on your compiler settings and use of the standard Java @Override annotation.Because of the upgrade to Prototype 1.7, existing JavaScript that uses value.toJSON() may break; replace with Object.toJSON(value).Some number of interfaces and APIs in Tapestry 5.3 will be removed in Tapestry 5.4 or later. These include:The http://tapestry.apache.org/5.2/apidocs/org/apache/tapestry5/RenderSupport.html;>RenderSupport environmental (replaced with the http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/services/javascript/JavaScriptSupport.html;>JavaScriptSupport environmental)The http://tapestry.apache.org/5.2/apidocs/org/apache/tapestry5/ajax/MultiZoneUpdate.html;>MultiZoneUpdate object, replaced with http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/services/ajax/AjaxR esponseRenderer.html">AjaxResponseRendererClassFactory service and ClassFab interface (replaced with the http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/ioc/services/PlasticProxyFactory.html;>PlasticProxyFactory service and http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/plastic/PlasticClass.html;>PlasticClass interface)The "suppress redirects" functionality, which allows component event requests to respond directly with HTML, as in Tapestry 4.New FeaturesUnderscore.jsTapestry now bundles http://underscorejs.org/; rel="nofollow">Underscore.js, a useful library for expressive functional programming in the browser. It is used in no conflict mode, made available as the T5._ object.User AlertsTapestry now has a central mechanism for handling user alerts; this includes the AlertManager service and the Alerts component. Just add an Alerts component to your application's standard layout component and Tapestry takes care of the rest. Alerts can be added during both traditional and Ajax requests, and may be transient (displayed for a few seconds), normal, or sticky (persist until the user expressly dismisses them). Alerts support three severities: info, warn(ing) and error; the look and feel can be customized by overriding Tapestry's default
svn commit: r1084348 [1/2] - in /websites/production/tapestry/content: ./ cache/
Author: buildbot Date: Sun Oct 8 10:12:16 2023 New Revision: 1084348 Log: Production update by buildbot for tapestry Modified: websites/production/tapestry/content/beaneditform-faq.html websites/production/tapestry/content/cache/main.pageCache websites/production/tapestry/content/component-events-faq.html websites/production/tapestry/content/component-parameters.html websites/production/tapestry/content/forms-and-validation.html websites/production/tapestry/content/javascript-faq.html websites/production/tapestry/content/page-navigation.html websites/production/tapestry/content/release-notes-50.html websites/production/tapestry/content/release-notes-51.html websites/production/tapestry/content/release-notes-52.html websites/production/tapestry/content/release-notes-53.html websites/production/tapestry/content/release-upgrade-faq.html websites/production/tapestry/content/request-processing-faq.html websites/production/tapestry/content/security-faq.html websites/production/tapestry/content/session-storage.html websites/production/tapestry/content/templating-and-markup-faq.html Modified: websites/production/tapestry/content/beaneditform-faq.html == --- websites/production/tapestry/content/beaneditform-faq.html (original) +++ websites/production/tapestry/content/beaneditform-faq.html Sun Oct 8 10:12:16 2023 @@ -143,11 +143,11 @@ BeanEditFormMain Article: BeanEditForm GuideContents/**/ +/*]]>*/ Why do I get exceptions about instantiating a bean when using BeanEditForm?What's the difference between BeanEditor and BeanEditForm?How do I customize the layout of the BeanEditForm? Why do I get exceptions about instantiating a bean when using BeanEditForm?When you render a BeanEditForm, or when the rendered form is submitted, Tapestry must instantiate an instance of the object to be edited. This occurs when the BeanEditForm's object parameter is bound to null: Tapestry instantiates an instance of the property type so that the BeanEditForm has an object to read default values from, or to push submitted values into.By default, this uses the standard injection mechanism, which means that Tapestry will identify the public constructor with the most parameters, and attempt to find objects and other objects for each constructor parameter.There's two ways to fine tune this so you don't get errors:Place an @http://tapestry.apache.org/current/apidocs/org/apache /tapestry5/ioc/annotations/Inject.html">Inject annotation on the correct constructor to use (often, the constructor with no parameters). public class MyBean { Modified: websites/production/tapestry/content/cache/main.pageCache == Binary files - no diff available. Modified: websites/production/tapestry/content/component-events-faq.html == --- websites/production/tapestry/content/component-events-faq.html (original) +++ websites/production/tapestry/content/component-events-faq.html Sun Oct 8 10:12:16 2023 @@ -143,11 +143,11 @@ Component EventsMain Article: Component EventsContents/**/ +/*]]>*/ Why does Tapestry send a redirect after a form is submitted?I specified a zone in my ActionLink/EventLink, so why doesn't my event fire via ajax (request.isXHR() is false)? Why does Tapestry send a redirect after a form is submitted?This is an extension of the http://en.wikipedia.org/wiki/Post/Redirect/Get; rel="nofollow">Post/Redirect/Get approach. It ensures that after an operation that updates server-side state, such as a form submission, if the user resubmits the resulting page, the operation is not performed a second time; instead just the results of the operation, reflecting the changed server-side state, is re-rendered.This has the unwanted requirement that any data needed to render the response must persist between the event request (the form submission) and the render request; this often means that fields must be annotated with