Replacing values in a string

45 views
Skip to first unread message

Joseph Wager

unread,
Aug 25, 2021, 2:56:06 PM8/25/21
to Moqui Ecosystem

I’m trying to capture some page info to throw into header tags. i’m getting the data I want using this:

set field=“pageTitle” from=“sri.screenUrlInfo.extraPathNameList”

but the string I’m getting has some non-alpha characters in it. Specifically the left and right bracket [ ]
To experiment, I tried just getting rod of the alpha ‘a’ in the string.

set field=“pageTitle” from=“sri.screenUrlInfo.extraPathNameList.replaceAll(‘a’,’ ')”

I’ve tried several different permutations, but get the following error:

No signature of method: java.util.ArrayList.replaceAll() is applicable for argument types: (String, String) values: [a, ]

Is there a better way to manipulate string values once I’ve captured them in a field?

Solomon Bessire

unread,
Aug 25, 2021, 4:16:20 PM8/25/21
to Moqui Ecosystem
I'm not sure if this is what you're after, but this is what we use to grab the screen title and expand anything inside it.  It isn't a list.  If you don't have anything to expand, you can omit the expand() call.

ec.resource.expand(sri.screenUrlInfo.targetScreen.getDefaultMenuName(),'')

Joseph Wager

unread,
Aug 25, 2021, 4:52:35 PM8/25/21
to Moqui Ecosystem
That does return a string without the brackets, so that's good. Unfortunately, it's the node of the url above the page I'm rendering.

e.g., in "http://localhost:8080/.../content/Ancient+Traditions" it's giving me "content" when I want "Ancient+Traditions".

Taher Alkhateeb

unread,
Aug 25, 2021, 6:15:55 PM8/25/21
to mo...@googlegroups.com

I might be stating the obvious but the error is self explanatory isn't it? You are not getting back a string but rather a List. And the method "replaceAll" is for strings. You're not getting back non-alpha characters, it's just a List [1]. You need to simply traverse the list to get what you need, either by specifying index, or looping or whatever makes it work for you

[1] org.moqui.impl.screen.ScreenUrlInfo -> ArrayList<String> extraPathNameList = (ArrayList<String>) null

--
You received this message because you are subscribed to the Google Groups "Moqui Ecosystem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moqui+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/moqui/41ca147d-b52b-4e1b-be7b-ebfe46bb5482n%40googlegroups.com.

Joseph Wager

unread,
Aug 26, 2021, 9:39:45 AM8/26/21
to Moqui Ecosystem
That is, in fact, the case, though it's not obvious to those of us who are less familiar with Java and Groovy. Grabbing the 0th instance of the array seems to work.
Reply all
Reply to author
Forward
0 new messages