You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Todd Patrick <To...@dtn.com> on 2006/06/09 18:15:18 UTC

If I have a component that is rendered by an ActionEvent, how to I keep the component rendered on the page if I rerun the even?

I have the following tree2 (that is working... horray!) that is
displayed based on a call to an ActionEvent:
 
<t:tree2
id="clientTree"
value="#{tbrowser.treeData}"
var="node"
varNodeToggler="t"
showRootNode="false"
rendered="#{tbrowser.displaytree}">
 
In my backing bean, I have the following code defined:
 
private boolean displaytree;
 
public boolean isDisplaytree() {
    return displaytree;
}
    
public void setDisplaytree(boolean _displaytree) {
    this.displaytree = _displaytree;
}
 
public void transTypeSelected(ActionEvent event) {
...
    this.displaytree = !this.displaytree;
    FacesContext.getCurrentInstance().renderResponse();
}
 
When I click on the h:commandButton:
 
<h:commandButton value="Search"
actionListener="#{tbrowser.transTypeSelected}"/>
 
Everything displays as I expected.
 
The second time I click on the h:commandButton, I return an error
"java.lang.IllegalArgumentException: Unable to locate facet with the
name: index"; which basically breaks my TreeNodeBase:
 
TreeNode treeData = new TreeNodeBase("index", "Transactions", false);
 
I believe that after I set the displaytree value (rendered) to true then
back to false, my Java tree code can't find the tree2 component.
 
Thoughts on how to fix this, do I just refresh the tree? How do I
accomplish that?
 
Thanks,
 
--Todd

Re: If I have a component that is rendered by an ActionEvent, how to I keep the component rendered on the page if I rerun the even?

Posted by Matthias Wessendorf <ma...@apache.org>.
just a quick guess:

-try to remove the renderResponse()
-use immidate="true" on the commandButton, which is invoking your actionListener

On 6/9/06, Todd Patrick <To...@dtn.com> wrote:
>
>
> I have the following tree2 (that is working... horray!) that is displayed
> based on a call to an ActionEvent:
>
> <t:tree2
> id="clientTree"
> value="#{tbrowser.treeData}"
> var="node"
> varNodeToggler="t"
> showRootNode="false"
> rendered="#{tbrowser.displaytree}">
>
> In my backing bean, I have the following code defined:
>
> private boolean displaytree;
>
> public boolean isDisplaytree() {
>     return displaytree;
> }
>
> public void setDisplaytree(boolean _displaytree) {
>     this.displaytree = _displaytree;
> }
>
> public void transTypeSelected(ActionEvent event) {
> ...
>     this.displaytree = !this.displaytree;
>     FacesContext.getCurrentInstance().renderResponse();
> }
>
> When I click on the h:commandButton:
>
> <h:commandButton value="Search"
> actionListener="#{tbrowser.transTypeSelected}"/>
>
> Everything displays as I expected.
>
> The second time I click on the h:commandButton, I return an error
> "java.lang.IllegalArgumentException: Unable to locate facet
> with the name: index"; which basically breaks my TreeNodeBase:
>
> TreeNode treeData = new TreeNodeBase("index", "Transactions", false);
>
> I believe that after I set the displaytree value (rendered) to true then
> back to false, my Java tree code can't find the tree2 component.
>
> Thoughts on how to fix this, do I just refresh the tree? How do I accomplish
> that?
>
> Thanks,
>
> --Todd


-- 
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com