0

In my XHTML I declared a variable using c:set:

<c:set var="valueObjectType" value="#{cc.attrs.valueObjectType}"
                scope="view" />

Is there a way to change "valueObjectType" on commandButton click?

Thanks in advance,

Emilio Numazaki
  • 836
  • 1
  • 5
  • 25
  • Start by reading https://stackoverflow.com/questions/3342984/jstl-in-jsf2-facelets-makes-sense – Kukeltje Oct 14 '17 at 13:25
  • Hello @Kukeltje! Thank you for sharing this (very) rich source of information. I read everything you sent in this post and my conclusion is that variables set through c:set cannot be changed, is that correct? If so, how do I create a kind of "global" variable, valid to a specific page? Let suppose I have "container" page and fragments that will be changed based on user interaction, how do I create a variable that is accessible by any fragments loaded in "placeholder"? – Emilio Numazaki Oct 14 '17 at 13:44
  • The reason I need this behavior is that I need to pass a managed bean reference from one fragment to other. Is there a way to do it through a attribute set in a managed bean? What do you suggest? – Emilio Numazaki Oct 14 '17 at 13:44
  • Hey @Kukeltje, I believe I found the reason it doesn't work when variable is set as "request" scope. The reason is that actionListener from commandButton is set during render (or before) time and cannot be changed dynamically. With this in mind, is there a way to workaround it? – Emilio Numazaki Oct 15 '17 at 03:06
  • There are several Q/A in Stackoverflow that are about passing values from one page to another – Kukeltje Oct 15 '17 at 13:11
  • Hello, actually, pass variable between pages is straightforward but look, I have a special requirement which is pass managed bean and actionListener to next page. What is happening is that actionListener is evaluated during render phase this is the reason "request" parameter is not working. I'm analysing a way to do it through binding where I can get bean and actionListener names from parameter and bind it dynamically to commandButton during composite render. – Emilio Numazaki Oct 15 '17 at 16:06
  • Then see if a viewaccesscoped bean can help. Might be simpeler. But In wonder where this complex requirements Comes from? – Kukeltje Oct 16 '17 at 06:48
  • @Kukeltje, I believe I found the final solution. In the end, I need to create Primeface's CommandButton programatically. This way I can read f:param from caller, instantiate a MethodExpressionActionListener, according to info configured, add actionListener to commandButton and bind it. I'll post an answer with complete solution soon. But thanks to you I realized what was wrong, I mean, actionListener is bound during render and this is the secret. Bind and configure programatically. Finally, this complex requirement comes from the need to create reusable UI component with simple usage – Emilio Numazaki Oct 16 '17 at 18:10
  • I have a re-usable/configurable ui too but no need for binding or other things like this... Using xhtml in a dynamic way hot rid of the programmatic Creation of the components. – Kukeltje Oct 16 '17 at 19:12

0 Answers0