Skip to content

Commit cf12b79

Browse files
Support omission of 'item' binding in NGPopUpButton
1 parent 01e1f6e commit cf12b79

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ng-appserver/src/main/java/ng/appserver/elements/NGPopUpButton.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,26 @@ public void appendToResponse( final NGResponse response, final NGContext context
151151
int index = 0;
152152

153153
for( Object object : list ) {
154-
// Set the value of the item binding in our current context
155-
// FIXME: we have to assume that item isn't neccessarily bound // Hugi 2023-05-01
156-
_itemAss.setValue( object, context.component() );
154+
155+
// Set the value of the item binding if bound
156+
if( _itemAss != null ) {
157+
_itemAss.setValue( object, context.component() );
158+
}
157159

158160
// Set the value of the index binding if bound
159161
if( _indexAss != null ) {
160162
_indexAss.setValue( index, context.component() );
161163
}
162164

163-
final Object displayString = _displayStringAss.valueInComponent( context.component() );
165+
final Object displayString;
166+
167+
if( _displayStringAss != null ) {
168+
displayString = _displayStringAss.valueInComponent( context.component() );
169+
}
170+
else {
171+
final Object current = list.get( index );
172+
displayString = current != null ? current.toString() : "<null>";
173+
}
164174

165175
boolean isSelected = false;
166176

0 commit comments

Comments
 (0)