users@javaserverfaces.java.net

RE: Re: A concept question. How do I initially hide (do not render) a component initially on a page?

From: Todd Patrick <Todd.Patrick_at_dtn.com>
Date: Thu, 12 Apr 2007 13:32:15 -0500

Well everything works great... expect, how do I hide the component
again?

The following doesn't work:

FacesContext context = FacesContext.getCurrentInstance();
UIViewRoot view = context.getViewRoot(); HtmlPanelGroup box =
(HtmlPanelGroup) view.findComponent("transactionDetailsBox");
box.setRendered(false);

I don't understand why this is such a pain?

I just want to hide and display a HtmlPanelGroup component by calling an
Action, that's it.

I'd appreciate any help.

Thanks,

--Todd



-----Original Message-----
From: Roger.Kitain_at_Sun.COM [mailto:Roger.Kitain_at_Sun.COM]
Sent: Wednesday, April 11, 2007 11:03 AM
To: users_at_javaserverfaces.dev.java.net
Subject: Re: A concept question. How do I initially hide (do not render)
a component initially on a page?

Assuming that

transactionDetailsBox


is a PanelGroup component you can try:

<h:panelGroup binding="#{tbrowser.transactionDetailsBox}".....


Todd Patrick wrote:

>Thank you, this worked:
>
>FacesContext context = FacesContext.getCurrentInstance();
>UIViewRoot view = context.getViewRoot(); HtmlPanelGroup box =
>(HtmlPanelGroup) view.findComponent("transactionDetailsBox");
>box.setRendered(true);
>
>
>What I am curious is why wouldn't a binded backing bean property work?
>For example, I did try:
>
><h:panelGroup text="#{tbrowser.transactionDetailsBox}"
> rendered="false"
> id="transactionDetailsBox">
>
>When I call the following statement in my action listener:
>
>this.getTransactionDetailsBox().setRendered(true);
>
>I receive a NullPointerException on the same statement.
>
>Why doesn't a binding value expression work for this?
>
>Thanks,
>
>--Todd
>
>
>
>-----Original Message-----
>From: Roger.Kitain_at_Sun.COM [mailto:Roger.Kitain_at_Sun.COM]
>Sent: Wednesday, April 11, 2007 9:23 AM
>To: users_at_javaserverfaces.dev.java.net
>Subject: Re: A concept question. How do I initially hide (do not
>render) a component initially on a page?
>
>In your page for the component you don't want rendered, add
>rendered="false"
>So when the pag is first rendered, the component should not appear.
>
>Then in your action method find that component in the view and set the
>rendered attribute to true.
>
>-roger
>
>Todd Patrick wrote:
>
>
>
>>I have the following:
>>private boolean panelDisplayed = false; public boolean
>>isPanelDisplayed() { return this.panelDisplayed; }
>>
>>public void setPanelDisplayed(boolean panelDisplayed) {
>>this.panelDisplayed = panelDisplayed; } public void
>>doFreeFormSearch(ActionEvent event) { this.setPanelDisplayed(true);
>>...
>>}
>>The issue is my h:panelGroup is still initially displayed. I put:
>>this.setPanelDisplayed(false);
>>in my constructor and the component is still displayed, so what do I
>>need to do to have the h:panelGroup initially hidden?
>>Thanks,
>>--Todd
>>
>>----------------------------------------------------------------------
>>--
>>*From:* Adam Brod [mailto:ABrod_at_intralinks.com]
>>*Sent:* Friday, April 06, 2007 7:47 AM
>>*To:* users_at_javaserverfaces.dev.java.net
>>*Subject:* Re: A concept question. How do I initially hide (do not
>>render) a component initially on a page?
>>
>>
>>What I would do is something like:
>>
>><h:panelGroup rendered="#{myBean.panelDisplayed}">
>>// some markup with jsf components
>></h:panelGroup>
>>
>><h:commandLink value="Render The Panel" action="#{myBean.showPanel}"/>
>>
>>In your backing bean (myBean), you'd have two methods:
>>
>>public boolean isPanelDisplayed() {
>>return this.isPanelDisplayed;
>>}
>>
>>public String showPanel() {
>>// some business logic maybe
>>
>>this.isPanelDisplayed = true;
>>return null; // this will render the same page again }
>>
>>I hope this helps.
>>*
>>Adam Brod*/
>>Product Development Team/
>>
>>
>>
>>From: "Todd Patrick" <Todd.Patrick_at_dtn.com>
>>To: <users_at_javaserverfaces.dev.java.net>
>>Date: 04/05/2007 04:20 PM
>>Subject: A concept question. How do I initially hide (do not
>>
>>
>render)
>
>
>>a component initially on a page?
>>
>>
>>----------------------------------------------------------------------
>>--
>>
>>
>>I am trying to figure out the following, which I can code - but I am
>>unsure about the proper approach.
>>
>>I have a UIPanel with children on a single JSF page.
>>
>>What I want is to not render - UIPanel.setRendered(false) - the first
>>time the page loads. I only want to render the UIPanel within a
>>condition inside an Action, i.e. a user clicks on a HtmlCommandButton.
>>
>>So my question is what is the best way to approach this? What is the
>>right concept?
>>
>>Do I have the UIPanel with children in the JSF page and set the
>>UIPanel.setRendered(false) in the backing bean constructor?
>>
>>Do I have an empty UIPanel binded to a backing bean property and in
>>Java code add the children?
>>
>>What is the **best** or **correct** way to approach this concept?
>>
>>Thanks,
>>
>>--Todd
>>
>>NOTICE: This email message is for the sole use of the intended
>>recipient(s) and may contain confidential and privileged information.
>>Any unauthorized use, disclosure or distribution is prohibited. If you
>>
>>
>
>
>
>>are not the intended recipient, please contact the sender by reply
>>email and destroy all copies of the original message.
>>
>>Disclaimer: This electronic mail and any attachments are confidential
>>
>>
>and may be privileged. If you are not the intended recipient, please
>notify the sender immediately by replying to this email, and destroy
>all copies of this email and any attachments. Thank you.
>
>
>>
>>
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
>For additional commands, e-mail:
>users-help_at_javaserverfaces.dev.java.net
>
>
>-----------------------------------------
>NOTICE: This email message is for the sole use of the intended
>recipient(s) and may contain confidential and privileged information.
>Any unauthorized use, disclosure or distribution is prohibited. If you
>are not the intended recipient, please contact the sender by reply
>email and destroy all copies of the original message.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
>For additional commands, e-mail:
>users-help_at_javaserverfaces.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: users-help_at_javaserverfaces.dev.java.net