Question
Pegasystems Inc.
JP
Last activity: 4 Oct 2018 13:54 EDT
7.1.9 How to remove page group or page list element within a single loop
I got "java.lang.UnsupportedOperationException: use ClipboardPage.remove(Object) " run-time exception, if I was trying to remove element of a page group property, (i.e. Work-.pyWorkParty) within a single loop using Engine API.
Is this a known issue or am I missing something here? Below is my java step.
//get iterator for pyWorkParty page group
java.util.Iterator pyWorkPartyIterator = tools.getPrimaryPage().getProperty("pyWorkParty").iterator();
// loop the pyWorkParty
while(pyWorkPartyIterator.hasNext()){
// get workParty
ClipboardPage currentWorkParty = ((ClipboardProperty)pyWorkPartyIterator.next()).getPageValue();
// if the workParty is Assignee, remove it.
if("Assignee".equalsIgnoreCase(currentWorkParty.getString("pxPartyRole"))){
pyWorkPartyIterator.remove(); // this step throws run-time exception
}
}
Below is the Engine API Java doc.
com.pega.pegarules.pub.clipboard
Interface ClipboardProperty
iterator
java.util.Iterator iterator()
Returns an iterator allowing access to values contained in this list, page, or group property. Note that this iterator reflects the contents of this property at the time of its creation. Further changes to this property will not be reflected in this iterator.
I got "java.lang.UnsupportedOperationException: use ClipboardPage.remove(Object) " run-time exception, if I was trying to remove element of a page group property, (i.e. Work-.pyWorkParty) within a single loop using Engine API.
Is this a known issue or am I missing something here? Below is my java step.
//get iterator for pyWorkParty page group
java.util.Iterator pyWorkPartyIterator = tools.getPrimaryPage().getProperty("pyWorkParty").iterator();
// loop the pyWorkParty
while(pyWorkPartyIterator.hasNext()){
// get workParty
ClipboardPage currentWorkParty = ((ClipboardProperty)pyWorkPartyIterator.next()).getPageValue();
// if the workParty is Assignee, remove it.
if("Assignee".equalsIgnoreCase(currentWorkParty.getString("pxPartyRole"))){
pyWorkPartyIterator.remove(); // this step throws run-time exception
}
}
Below is the Engine API Java doc.
com.pega.pegarules.pub.clipboard
Interface ClipboardProperty
iterator
java.util.Iterator iterator()
Returns an iterator allowing access to values contained in this list, page, or group property. Note that this iterator reflects the contents of this property at the time of its creation. Further changes to this property will not be reflected in this iterator.
- Returns:
- the iterator. For most properties, the objects returned by Iterator.next() are ClipboardProperty instances. Lightweight page lists are the exception; in this case the objects are String arrays (String[]).
- Throws:
-
WrongModeException
- this property does not contain a list, page, or group
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.