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.
>
>
>