You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ng-appserver/src/main/java/ng/appserver/templating/elements/NGPopUpButton.java
+46-52Lines changed: 46 additions & 52 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@
6
6
importjava.util.HashMap;
7
7
importjava.util.List;
8
8
importjava.util.Map;
9
+
importjava.util.SequencedCollection;
9
10
10
11
importng.appserver.NGContext;
11
12
importng.appserver.NGRequest;
@@ -18,34 +19,24 @@
18
19
19
20
/**
20
21
* FIXME: Add support for <optgroup> // Hugi 2024-07-13
22
+
* FIXME: Currently always using an item's index in the original 'list' as an option's "value". We're missing a 'value' association to allow a custom value to go through to the generated request parameters // Hugi 2023-05-01
23
+
* FIXME: Currently always replacing the value of the targeted "selections" binding with a new List. Having the option to modify an existing collection might be good.
* FIXME: We might want to offer the opportunity to replace the entire "selections" association in the target component, instead of modifying the existing collection // Hugi 2024-07-13
// FIXME: We might want to offer th user the opportunity that we modify the original collection instead of passing in a new one // Hugi 2024-07-13
80
+
// FIXME: OK, we have something of a problem with NGBrowser.
81
+
// Selecting no objects in the UI results in it not being represented in the request's formValues at all (no value present for it's 'name').
82
+
// This means that in the case of multiple forms on the same page and a form being submitted - we don't actually know if the value should be set to an empty list (we don't know if the containing form was submitted or if it was a different form).
83
+
// The only way I can think of to make this work is if we can check if the actual *form* containing the current browser is being submitted. In that case, we can definitely interpret the absence of a value as "no values selected".
84
+
// The current functionality means that if a browser is in one form on a page and a different form is submitted, the browser will always interpret that as "no values selected".
85
+
// Hugi 2025-08-04
93
86
finalList<?> list = list( context );
94
87
95
88
finalListselectedItems = newArrayList<>();
@@ -101,24 +94,26 @@ private void takeMultipleValuesFromRequest( final NGContext context, final Strin
// If multiple form values are present for the same field name, the potential for an error condition is probably high enough to just go ahead and fail.
107
-
if( valuesFromRequest.size() > 1 ) {
108
-
thrownewIllegalStateException( "The request contains %s form values named '%s'. I can only handle one at a time. The values you sent me are (%s).".formatted( valuesFromRequest.size(), name, valuesFromRequest ) );
109
-
}
99
+
if( !valuesFromRequest.isEmpty() ) {
100
+
// If multiple form values are present for the same field name, the potential for an error condition is probably high enough to just go ahead and fail.
101
+
if( valuesFromRequest.size() > 1 ) {
102
+
thrownewIllegalStateException( "The request contains %s form values named '%s'. I can only handle one at a time. The values you sent me are (%s).".formatted( valuesFromRequest.size(), name, valuesFromRequest ) );
isSelected = selectedIndexes.contains( String.valueOf( index ) );
182
-
183
-
// FIXME: We're doing a separate round here to check for current selections in the associated list. This is spaghetti logic by now, fix up // Hugi 2025-05-25
// FIXME: We're currently always using the index as "value". We're going to want to allow the passing in of a custom value attribute through the value binding // Hugi 2023-05-01
thrownewIllegalArgumentException( "NGRepetition only accepts java.util.List and java Arrays. You sent me a %s".formatted( listAssociationValue.getClass() ) );
// CHECKME: Ideally we don't want to convert the sequenced collection to a new List. However, making it redundant requires us to rethink/redesign how we're currently iterate over the list (by index) so here we are // Hugi 2024-09-30
258
+
returnList.of( sc.toArray() );
259
+
}
260
+
261
+
thrownewIllegalArgumentException( "%s only accepts java.util.List, java arrays and java.util.SequencedCollection. You sent me a %s".formatted( getClass().getSimpleName(), listAssociationValue.getClass() ) );
0 commit comments