By: Adam Boxall user 19 Jun 2019 at 3:39 a.m. CDT

3 Responses
Adam Boxall gravatar
Hi I'm trying to iterate through a list of maps using `<ui:repeat />` within a JSF template that accompanies an interception script. I'm using the `identity.setWorkingParameter()` and `identity.getWorkingParameter()` methods for persisting the collection between steps (with the correct key included in the list returned from the `getExtraParametersForStep` hook). Regardless of whether I define the collection as a Python list of dictionaries, or a Java list of hash maps, I'm unable to recover its value in subsequent steps. It is however available if I retrieve it immediately after setting in the _same_ step, which suggests it could be a serialisation problem between HTTP requests. Backing that theory up somewhat, if I serialise both collections into a JSON string myself manually (using Jackson for the Java and json.dumps for the Python), the values persist into subsequent steps as would be expected. That unfortunately breaks the template though because JSF can't of course iterate through a JSON string. Python approach: ``` identity.setWorkingParameter("items", [ {"title": "foo"}, {"title": "bar"} ]) ``` Java approach: ``` item1 = HashMap() item1.put("title", "foo") item2 = HashMap() item2.put("title", "bar") identity.setWorkingParameter("items", Arrays.asList(item1, item2)) ``` JSF template code: ``` <ui:repeat value="#{identity.getWorkingParameter('items').entrySet().toArray()}" var="item"> <p> <h:outputText value="#{item.title}" /> </p> </ui:repeat> ``` For both approaches I would expect/hope to see two `<p>` paragraphs rendered, but in-fact there is nothing rendered and there are no errors reported (that I can find at least). Similarly if I `print` the value of those parameters in the subsequent step/request I get `None`, except when I've serialised them manually. Is it possible to store complex data structures in the _working parameters_, and if so what do I need to do to ensure that they're persisted across steps/requests? Is trying to use pure Python over Java recommended? Any help is much appreciated. Thanks, Adam

By William Lowe user 19 Jun 2019 at 5:44 a.m. CDT

William Lowe gravatar
Hi Adam, Which type of script is this? e.g. Person Authentication, Consent, or something else?

By Adam Boxall user 19 Jun 2019 at 5:44 a.m. CDT

Adam Boxall gravatar
Hi William This is a Person Authentication script. Thanks, Adam

By Yuriy Movchan staff 19 Jun 2019 at 3:42 p.m. CDT

Yuriy Movchan gravatar
Hi Adam, You can set temporary any object to `identiy.setWorkingParameter` and use it during rendering JSF phase. You can do this in `prepareForStep`. But if you need to persist parameter in session you need to use primitive types. Also you need to inform Authneticator which parameter from `identity.workingParameters` it should persist. You can do this via method: ``` def getExtraParametersForStep(self, configurationAttributes, step): if step == 1: return Arrays.asList("items") return None ``` In scripts which I developed I use JSON if I need to strore complex object in session. In order to use map in JSF you can do for example next: 1. Put into `identity.setWorkingParameter` 2 parameters with map and JSON 2. Implement `getExtraParametersForStep` to store only parameter with JSON value 3. Add logic into `prepareForStep` to get JSON parameter and set map parameter into identity.setWorkingParameter again. There are also other examples in oxAuth [repo](https://github.com/GluuFederation/oxAuth/tree/master/Server/integrations). Regards, Yuriy