update attribute not working as expected while trying to render panels conditionally
up vote
0
down vote
favorite
I am trying to show/hide my panels based upon a boolean value present on the backing bean but it's not working as expected and there is no change on the UI.
This works fine for the first time (only one of the panels is shown) when the app loads but then after there is no update performed.
I know that for the update to be performed, the element should exist in the dom already so it doesn't update the panel which is not rendered by the server . But my query is why the other panel (shown when the app loads) doesn't get hidden when the boolean condition changes.
xhtml file
<p:panel>
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Case
Type</h6>
<!-- comment type -->
<p:selectOneListbox id="caseTypeId"
value="#{treeBean.caseTypeOption}">
<f:selectItems value="#{treeBean.caseType}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
<p:ajax listener="#{treeBean.caseTypeList}" update=":#{p:component('panel2')} :#{p:component('panel3')}"/>
</p:selectOneListbox>
</p:panel>
<p:panel id="panel2" rendered="#{treeBean.editmode}">
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Something
</h6>
<p:selectOneListbox id="somethingId"
value="#{treeBean.somethingOption}">
<f:selectItems value="#{treeBean.something}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
</p:selectOneListbox>
</p:panel>
<p:panel id="panel3" rendered="#{!treeBean.editmode}">
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Anything
</h6>
<p:selectOneListbox id="anythingId"
value="#{treeBean.anythingOption}">
<f:selectItems value="#{treeBean.anything}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
</p:selectOneListbox>
</p:panel>
</h:panelGrid>
Backing bean (omitting details)
if (this.caseTypeOption.equalsIgnoreCase("XXX")) {
this.editmode = false;
} else {
this.editmode = true;
}
wher XXX is one of the options in caseTypeId select box.
How to make this work for both the panels ??
jsf primefaces
add a comment |
up vote
0
down vote
favorite
I am trying to show/hide my panels based upon a boolean value present on the backing bean but it's not working as expected and there is no change on the UI.
This works fine for the first time (only one of the panels is shown) when the app loads but then after there is no update performed.
I know that for the update to be performed, the element should exist in the dom already so it doesn't update the panel which is not rendered by the server . But my query is why the other panel (shown when the app loads) doesn't get hidden when the boolean condition changes.
xhtml file
<p:panel>
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Case
Type</h6>
<!-- comment type -->
<p:selectOneListbox id="caseTypeId"
value="#{treeBean.caseTypeOption}">
<f:selectItems value="#{treeBean.caseType}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
<p:ajax listener="#{treeBean.caseTypeList}" update=":#{p:component('panel2')} :#{p:component('panel3')}"/>
</p:selectOneListbox>
</p:panel>
<p:panel id="panel2" rendered="#{treeBean.editmode}">
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Something
</h6>
<p:selectOneListbox id="somethingId"
value="#{treeBean.somethingOption}">
<f:selectItems value="#{treeBean.something}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
</p:selectOneListbox>
</p:panel>
<p:panel id="panel3" rendered="#{!treeBean.editmode}">
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Anything
</h6>
<p:selectOneListbox id="anythingId"
value="#{treeBean.anythingOption}">
<f:selectItems value="#{treeBean.anything}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
</p:selectOneListbox>
</p:panel>
</h:panelGrid>
Backing bean (omitting details)
if (this.caseTypeOption.equalsIgnoreCase("XXX")) {
this.editmode = false;
} else {
this.editmode = true;
}
wher XXX is one of the options in caseTypeId select box.
How to make this work for both the panels ??
jsf primefaces
Possible duplicate of Ajax update/render does not work on a component which has rendered attribute
– Kukeltje
Nov 19 at 10:59
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to show/hide my panels based upon a boolean value present on the backing bean but it's not working as expected and there is no change on the UI.
This works fine for the first time (only one of the panels is shown) when the app loads but then after there is no update performed.
I know that for the update to be performed, the element should exist in the dom already so it doesn't update the panel which is not rendered by the server . But my query is why the other panel (shown when the app loads) doesn't get hidden when the boolean condition changes.
xhtml file
<p:panel>
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Case
Type</h6>
<!-- comment type -->
<p:selectOneListbox id="caseTypeId"
value="#{treeBean.caseTypeOption}">
<f:selectItems value="#{treeBean.caseType}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
<p:ajax listener="#{treeBean.caseTypeList}" update=":#{p:component('panel2')} :#{p:component('panel3')}"/>
</p:selectOneListbox>
</p:panel>
<p:panel id="panel2" rendered="#{treeBean.editmode}">
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Something
</h6>
<p:selectOneListbox id="somethingId"
value="#{treeBean.somethingOption}">
<f:selectItems value="#{treeBean.something}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
</p:selectOneListbox>
</p:panel>
<p:panel id="panel3" rendered="#{!treeBean.editmode}">
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Anything
</h6>
<p:selectOneListbox id="anythingId"
value="#{treeBean.anythingOption}">
<f:selectItems value="#{treeBean.anything}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
</p:selectOneListbox>
</p:panel>
</h:panelGrid>
Backing bean (omitting details)
if (this.caseTypeOption.equalsIgnoreCase("XXX")) {
this.editmode = false;
} else {
this.editmode = true;
}
wher XXX is one of the options in caseTypeId select box.
How to make this work for both the panels ??
jsf primefaces
I am trying to show/hide my panels based upon a boolean value present on the backing bean but it's not working as expected and there is no change on the UI.
This works fine for the first time (only one of the panels is shown) when the app loads but then after there is no update performed.
I know that for the update to be performed, the element should exist in the dom already so it doesn't update the panel which is not rendered by the server . But my query is why the other panel (shown when the app loads) doesn't get hidden when the boolean condition changes.
xhtml file
<p:panel>
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Case
Type</h6>
<!-- comment type -->
<p:selectOneListbox id="caseTypeId"
value="#{treeBean.caseTypeOption}">
<f:selectItems value="#{treeBean.caseType}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
<p:ajax listener="#{treeBean.caseTypeList}" update=":#{p:component('panel2')} :#{p:component('panel3')}"/>
</p:selectOneListbox>
</p:panel>
<p:panel id="panel2" rendered="#{treeBean.editmode}">
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Something
</h6>
<p:selectOneListbox id="somethingId"
value="#{treeBean.somethingOption}">
<f:selectItems value="#{treeBean.something}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
</p:selectOneListbox>
</p:panel>
<p:panel id="panel3" rendered="#{!treeBean.editmode}">
<h6 align="center" style="width: 14.7em; background-color: #ACBECE;">Anything
</h6>
<p:selectOneListbox id="anythingId"
value="#{treeBean.anythingOption}">
<f:selectItems value="#{treeBean.anything}" var="X"
itemLabel="#{X}" itemValue="#{X}" />
</p:selectOneListbox>
</p:panel>
</h:panelGrid>
Backing bean (omitting details)
if (this.caseTypeOption.equalsIgnoreCase("XXX")) {
this.editmode = false;
} else {
this.editmode = true;
}
wher XXX is one of the options in caseTypeId select box.
How to make this work for both the panels ??
jsf primefaces
jsf primefaces
asked Nov 19 at 9:04
Neeraj Chand
1228
1228
Possible duplicate of Ajax update/render does not work on a component which has rendered attribute
– Kukeltje
Nov 19 at 10:59
add a comment |
Possible duplicate of Ajax update/render does not work on a component which has rendered attribute
– Kukeltje
Nov 19 at 10:59
Possible duplicate of Ajax update/render does not work on a component which has rendered attribute
– Kukeltje
Nov 19 at 10:59
Possible duplicate of Ajax update/render does not work on a component which has rendered attribute
– Kukeltje
Nov 19 at 10:59
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
In the update action you should use only the name of the components that you want to update. In your case you should use update=":form:panel2, :form:panel3".
If this panels is in form you should use the form element before the name of the component, otherwise just the name of the component will make the trick.
that is what I have in my update attribute. update=":panel2, :panel3" and update=":#{p:component('panel2')} :#{p:component('panel3')}" are the same ryt ?
– Neeraj Chand
Nov 19 at 9:46
add a comment |
up vote
0
down vote
Instead of rendered attribute , using visible attribute helped me to achieve what I wanted.
So instead of <p:panel id="panel2" rendered="#{treeBean.editmode}">
I used : <p:panel id="panel2" visible="#{treeBean.editmode}">
This is expected yes - you can't update a component, which was never rendered. Your case will also work, when you update the parent component instead the children, which was not rendered yet.
– tandraschko
Nov 19 at 10:28
@tandraschko: as mentioned in the 'duplicate'
– Kukeltje
Nov 20 at 9:54
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
In the update action you should use only the name of the components that you want to update. In your case you should use update=":form:panel2, :form:panel3".
If this panels is in form you should use the form element before the name of the component, otherwise just the name of the component will make the trick.
that is what I have in my update attribute. update=":panel2, :panel3" and update=":#{p:component('panel2')} :#{p:component('panel3')}" are the same ryt ?
– Neeraj Chand
Nov 19 at 9:46
add a comment |
up vote
0
down vote
In the update action you should use only the name of the components that you want to update. In your case you should use update=":form:panel2, :form:panel3".
If this panels is in form you should use the form element before the name of the component, otherwise just the name of the component will make the trick.
that is what I have in my update attribute. update=":panel2, :panel3" and update=":#{p:component('panel2')} :#{p:component('panel3')}" are the same ryt ?
– Neeraj Chand
Nov 19 at 9:46
add a comment |
up vote
0
down vote
up vote
0
down vote
In the update action you should use only the name of the components that you want to update. In your case you should use update=":form:panel2, :form:panel3".
If this panels is in form you should use the form element before the name of the component, otherwise just the name of the component will make the trick.
In the update action you should use only the name of the components that you want to update. In your case you should use update=":form:panel2, :form:panel3".
If this panels is in form you should use the form element before the name of the component, otherwise just the name of the component will make the trick.
answered Nov 19 at 9:16
Jimmo
62
62
that is what I have in my update attribute. update=":panel2, :panel3" and update=":#{p:component('panel2')} :#{p:component('panel3')}" are the same ryt ?
– Neeraj Chand
Nov 19 at 9:46
add a comment |
that is what I have in my update attribute. update=":panel2, :panel3" and update=":#{p:component('panel2')} :#{p:component('panel3')}" are the same ryt ?
– Neeraj Chand
Nov 19 at 9:46
that is what I have in my update attribute. update=":panel2, :panel3" and update=":#{p:component('panel2')} :#{p:component('panel3')}" are the same ryt ?
– Neeraj Chand
Nov 19 at 9:46
that is what I have in my update attribute. update=":panel2, :panel3" and update=":#{p:component('panel2')} :#{p:component('panel3')}" are the same ryt ?
– Neeraj Chand
Nov 19 at 9:46
add a comment |
up vote
0
down vote
Instead of rendered attribute , using visible attribute helped me to achieve what I wanted.
So instead of <p:panel id="panel2" rendered="#{treeBean.editmode}">
I used : <p:panel id="panel2" visible="#{treeBean.editmode}">
This is expected yes - you can't update a component, which was never rendered. Your case will also work, when you update the parent component instead the children, which was not rendered yet.
– tandraschko
Nov 19 at 10:28
@tandraschko: as mentioned in the 'duplicate'
– Kukeltje
Nov 20 at 9:54
add a comment |
up vote
0
down vote
Instead of rendered attribute , using visible attribute helped me to achieve what I wanted.
So instead of <p:panel id="panel2" rendered="#{treeBean.editmode}">
I used : <p:panel id="panel2" visible="#{treeBean.editmode}">
This is expected yes - you can't update a component, which was never rendered. Your case will also work, when you update the parent component instead the children, which was not rendered yet.
– tandraschko
Nov 19 at 10:28
@tandraschko: as mentioned in the 'duplicate'
– Kukeltje
Nov 20 at 9:54
add a comment |
up vote
0
down vote
up vote
0
down vote
Instead of rendered attribute , using visible attribute helped me to achieve what I wanted.
So instead of <p:panel id="panel2" rendered="#{treeBean.editmode}">
I used : <p:panel id="panel2" visible="#{treeBean.editmode}">
Instead of rendered attribute , using visible attribute helped me to achieve what I wanted.
So instead of <p:panel id="panel2" rendered="#{treeBean.editmode}">
I used : <p:panel id="panel2" visible="#{treeBean.editmode}">
answered Nov 19 at 10:02
Neeraj Chand
1228
1228
This is expected yes - you can't update a component, which was never rendered. Your case will also work, when you update the parent component instead the children, which was not rendered yet.
– tandraschko
Nov 19 at 10:28
@tandraschko: as mentioned in the 'duplicate'
– Kukeltje
Nov 20 at 9:54
add a comment |
This is expected yes - you can't update a component, which was never rendered. Your case will also work, when you update the parent component instead the children, which was not rendered yet.
– tandraschko
Nov 19 at 10:28
@tandraschko: as mentioned in the 'duplicate'
– Kukeltje
Nov 20 at 9:54
This is expected yes - you can't update a component, which was never rendered. Your case will also work, when you update the parent component instead the children, which was not rendered yet.
– tandraschko
Nov 19 at 10:28
This is expected yes - you can't update a component, which was never rendered. Your case will also work, when you update the parent component instead the children, which was not rendered yet.
– tandraschko
Nov 19 at 10:28
@tandraschko: as mentioned in the 'duplicate'
– Kukeltje
Nov 20 at 9:54
@tandraschko: as mentioned in the 'duplicate'
– Kukeltje
Nov 20 at 9:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371294%2fupdate-attribute-not-working-as-expected-while-trying-to-render-panels-condition%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of Ajax update/render does not work on a component which has rendered attribute
– Kukeltje
Nov 19 at 10:59