I am having trouble passing a parameter to a dialog that I can actually use.
I have a command button which is is set with an actionListener
that calls an open dialog method in the backing bean
Map<String, Object> options = new HashMap<>();
options.put("modal", true);
//...
options.put("includeViewParams", true);
Map<String, List<String>> params = new HashMap<>();
List<String> values = new ArrayList<>();
values.add("My String");
params.put("myParam", values);
PrimeFaces.current().dialog().openDynamic("test", options, params);
then in my test page I gave
<f:metadata>
<f:viewParam name="myParam" value="#{testBean.testVal}" />
</f:metadata>
...
<h:outputText value="#{testBean.testVal}" />
and the string is output fine.
But I want to use that value in to perform a database lookup and this just isn't working.
private String myParam;
private List<Object> myThings;
@PostConstruct
public void init() {
myThings = service.lookup(myParam);
}
but in the PostConstruct
call myParam is null.
I added some logging on init
and the getter and setter and noticed I had
- init --> myParam null
- Getter --> myParam null
- Setter --> myParam = passed value
- Getter --> myParam = passed value
- Getter --> myParam = passed value
So it appears that the value is getting passed but after the PostConstuct
method has fired.
An I doing something wrong or should I be doing this another way? (I have seen reference of passing objects via the session map but is there a way of getting this working like this?)