@@ -88,6 +88,7 @@ public class CObjectArrayField
8888 private CPageInlineAction feedinginlineaction ;
8989 private CInlineActionDataRef feedinginlineactionoutputdata ;
9090 private Tooltip tooltip ;
91+ private boolean keeponlyone ;
9192
9293 /**
9394 * creates an object array field widget from a message from the server
@@ -144,6 +145,7 @@ public CObjectArrayField(MessageReader reader, CPageSignifPath parentpath) throw
144145 this .feedinginlineactionoutputdata = new CInlineActionDataRef (reader , this );
145146 reader .returnNextEndStructure ("INLACT" );
146147 }
148+ this .keeponlyone = reader .returnNextBooleanField ("KOO" );
147149 reader .returnNextEndStructure ("OBJARF" );
148150
149151 }
@@ -154,7 +156,8 @@ public CPageNode deepcopyWithCallback(Callback callback) {
154156 }
155157
156158 public ArrayDataElt <ObjectDataElt > getExternalContent (CPageData inputdata , CPageDataRef dataref ) {
157- if (dataref ==null ) return new ArrayDataElt <ObjectDataElt >("INPUTDATA" , new ObjectDataEltType ());
159+ if (dataref == null )
160+ return new ArrayDataElt <ObjectDataElt >("INPUTDATA" , new ObjectDataEltType ());
158161 DataElt thiselement = inputdata .lookupDataElementByName (dataref .getName ());
159162 if (thiselement == null )
160163 throw new RuntimeException (String .format ("could not find any page data with name = %s" , dataref .getName ()));
@@ -257,13 +260,14 @@ public DataElt getDataElt(DataEltType type, String eltname, String objectfieldna
257260 if (payloadtypeinarray instanceof ObjectDataEltType ) {
258261 ObjectDataEltType objecttype = (ObjectDataEltType ) payloadtypeinarray ;
259262 ArrayDataElt <ObjectDataElt > output = new ArrayDataElt <ObjectDataElt >(eltname , objecttype );
260- for (int i = 0 ; i < thiselementarray .getObjectNumber (); i ++) {
261- // fields are not sent back
262- ObjectDataElt thisobject = thiselementarray .getObjectAtIndex (i );
263- ObjectDataElt object = new ObjectDataElt (eltname );
264- object .setUID (thisobject .getUID ());
265- output .addElement (object );
266- }
263+ if (thiselementarray != null )
264+ for (int i = 0 ; i < thiselementarray .getObjectNumber (); i ++) {
265+ // fields are not sent back
266+ ObjectDataElt thisobject = thiselementarray .getObjectAtIndex (i );
267+ ObjectDataElt object = new ObjectDataElt (eltname );
268+ object .setUID (thisobject .getUID ());
269+ output .addElement (object );
270+ }
267271 return output ;
268272 }
269273 }
@@ -280,8 +284,11 @@ public void forceUpdateData(DataElt dataelt) {
280284 treated = true ;
281285 }
282286 if (dataelt instanceof ObjectDataElt ) {
287+
283288 ObjectDataElt element = (ObjectDataElt ) dataelt ;
289+ if (this .keeponlyone ) if (thiselementarray .getObjectNumber ()==1 ) thiselementarray .removeObjectAtIndex (0 );
284290 thiselementarray .addElement (element .deepcopy (thiselementarray .getName ()));
291+
285292 refreshDisplay ();
286293 treated = true ;
287294 }
0 commit comments