-
1. Re: Using expressions in rendered (or any other boolean attribute)
harut Mar 17, 2010 2:53 AM (in response to lenyas66)You should use "and"
rendered="#{renderPeriodicity and qtBeanParam.trailingVisible}"
-
2. Re: Using expressions in rendered (or any other boolean attribute)
lenyas66 Mar 17, 2010 6:14 PM (in response to harut)That doesn't work. here's the code snippet:
<
a4j:commandButton id="expRetExcel" value="Download Returns"
styleClass="command-button" rendered="#{renderPeriodicity and qtBeanParam.trailingVisible}"
action="#{qtBeanParam.genReturnsWorkBook}" immediate="false"
oncomplete="showResults(#{qtBeanParam.retRandNum}, #{qtBeanParam.hasExcelData})">
</a4j:commandButton>
Trailing visible gets set, when radio button value "trailing" is selected. Button is still visible, even when selectOneRadio has non-trailing value.
<
h:selectOneRadio id="periodType" value="#{qtBeanParam.curTimePeriod.periodType}" immediate="true"
required="true" valueChangeListener="#{qtBeanParam.periodTypeChange}">
<a4j:support event="onclick" reRender="sortingPanel,timePanel,expRetExcel" ajaxSingle="true" />
<f:selectItem id="itemT" itemLabel="Trailing" itemValue="TRAILING" />
<f:selectItem id="itemC" itemLabel="Calendar" itemValue="CALENDAR" />
<f:selectItem id="itemCus" itemLabel="Custom" itemValue="CUSTOM" />
</h:selectOneRadio>
...
public
logger.debug("<changeBenchmark>" + vce.getNewValue());
PhaseId phaseId = vce.getPhaseId();
final PeriodType pt = (PeriodType)vce.getNewValue();
if ( phaseId.equals(PhaseId.ANY_PHASE))
{
vce.setPhaseId(PhaseId.
UPDATE_MODEL_VALUES);
vce.queue();
}
else if ( phaseId.equals(PhaseId.UPDATE_MODEL_VALUES))
{
if (PeriodType.TRAILING == pt) {
trailingVisible = true;
calendarVisible = false;
customVisible = false;
allowSorting = true;
}
if(PeriodType.CALENDAR == pt) {
calendarVisible = true;
trailingVisible = false;
customVisible = false;
allowSorting = false;
//prevent any trailing periods from being processed
}
if(PeriodType.CUSTOM == pt) {
calendarVisible = false;
trailingVisible = false;
customVisible = true;
allowSorting = false;
//prevent any trailing periods from being processed
}
}
-
3. Re: Using expressions in rendered (or any other boolean attribute)
ufonaut Mar 17, 2010 11:39 PM (in response to lenyas66)If a string literal is not empty, it'll evaluate as true.
try :
ui:param name="renderPeriodicity" value="#{false}"/>
-
4. Re: Using expressions in rendered (or any other boolean attribute)
harut Mar 18, 2010 2:54 AM (in response to lenyas66)1 of 1 people found this helpfulThat doesn't work. here's the code snippet:
"and" is the correct EL expression, and you can't get your expected result because of another reson.
required="true" valueChangeListener="#{qtBeanParam.periodTypeChange}">
<a4j:support event="onclick" reRender="sortingPanel,timePanel,expRetExcel" ajaxSingle="true" />
<f:selectItem id="itemT" itemLabel="Trailing" itemValue="TRAILING" />
<f:selectItem id="itemC" itemLabel="Calendar" itemValue="CALENDAR" />
<f:selectItem id="itemCus" itemLabel="Custom" itemValue="CUSTOM" />
</h:selectOneRadio>
You are reRendering "expRetExcel" and that is the reason that the button still visible after non-trailing value. You should reRender another top level component which contains that commandButton -- e.g.
<h:panelGroup id="buttonsArea">
<a4j:commandButton id="expRetExcel" value="Download Returns"oncomplete="showResults(#{qtBeanParam.retRandNum}, #{qtBeanParam.hasExcelData})">
</a4j:commandButton>
</h:panelGroup>
and reRender "buttonsArea" in a4j:support. After that the button will become invisible...
-
5. Re: Using expressions in rendered (or any other boolean attribute)
ilya_shaikovsky Mar 18, 2010 3:27 AM (in response to ufonaut)yes. that should be the reason..
B.t.w. Harut, thanks for your efforts! Just for clarification we could not insert DOM element via ajax and should update the parents.. but removal should still work in his case althought it's still not preferable way for sure
-
6. Re: Using expressions in rendered (or any other boolean attribute)
harut Mar 18, 2010 3:49 AM (in response to ilya_shaikovsky)Hi Ilya, Glad to help in something!
Just for clarification we could not insert DOM element via ajax and should update the parents.. but removal should still work in his case althought it's still not preferable way for sure
I see... I had a same strange behavior as Leonid's case a year ago, and after finding a solution, all reRenders (for rendering some components) I am making on top level ones intuitively... so it becomes 'preferable' way for me
-
7. Re: Using expressions in rendered (or any other boolean attribute)
lenyas66 Mar 18, 2010 1:40 PM (in response to harut)Getting there, but not there yet :-)
I made the changes as suggested, but it is still rendered when trailingVisible is false. Any other ideas?
<
h:selectOneRadio id="periodType" value="#{qtBeanParam.curTimePeriod.periodType}" immediate="true"
required="true" valueChangeListener="#{qtBeanParam.periodTypeChange}">
<a4j:support event="onclick" reRender="sortingPanel,timePanel,exportReturns" ajaxSingle="true" />
<f:selectItem id="itemT" itemLabel="Trailing" itemValue="TRAILING" />
<f:selectItem id="itemC" itemLabel="Calendar" itemValue="CALENDAR" />
<f:selectItem id="itemCus" itemLabel="Custom" itemValue="CUSTOM" />
</h:selectOneRadio>
...
<
h:panelGroup id="exportReturns" rendered="#{qtBeanParam.trailingVisible}">
<a4j:commandButton id="expRetExcel" value="Download Returns"
styleClass="command-button" rendered="#{renderPeriodicity}"
action="#{qtBeanParam.genReturnsWorkBook}" immediate="false"
oncomplete="showResults(#{qtBeanParam.retRandNum}, #{qtBeanParam.hasExcelData})">
</a4j:commandButton>
</h:panelGroup>
-
piQueryToolCommon.xhtml.zip 3.4 KB
-
-
9. Re: Using expressions in rendered (or any other boolean attribute)
lenyas66 Mar 18, 2010 2:19 PM (in response to nbelaevski)This has worked!
Thanks a lot, Nick and everybody else for your valuable input.
Final version looks as follows:
<
a4j:outputPanel id="exportReturns" >
<a4j:commandButton id="expRetExcel" value="Download Returns"
styleClass="command-button" rendered="#{renderPeriodicity and qtBeanParam.trailingVisible}"
action="#{qtBeanParam.genReturnsWorkBook}" immediate="false"
oncomplete="showResults(#{qtBeanParam.retRandNum}, #{qtBeanParam.hasExcelData})">
</a4j:commandButton>
</a4j:outputPanel>