0

When page rendered first time textbox was empty and when i click a button and called a action and update the value like this it worked and textbox updated with new value

  Flash flash = FacesContext.getCurrentInstance().getExternalContext()
                .getFlash();

    flash.put("errorMessage",featuesObj.getName() + "Some Error came");

   <h:inputText value="#{flash.errorMessage }" id="mymessage" />

But now made a little changes in textbox and added a rendered now text box not displayed even pressing command button while #{flash.errorMessage} already have some String value

<h:inputText value="#{flash.errorMessage}" rendered="#{flash.errorMessage.length()  gt 0 }" id="mymessage" /> 

Even i tried below code as well

  <h:inputText value="#{flash.errorMessage.length()}"  id="mymessage" /> 

Its always showing false in textbox even i press the button.

Can someone please let me know what can be issue?

Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202
  • 1
    possible duplicate of [Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?](http://stackoverflow.com/questions/9010734/why-do-i-need-to-nest-a-component-with-rendered-some-in-another-component-w) – Kukeltje Aug 10 '15 at 13:49

1 Answers1

0

This is the answer of my problem

Ajax rendering of content which is by itself conditionally rendered

Ajax rendering takes place fully at the client side and expects the to-be-updated HTML element to be already in the JSF-generated HTML output.

Following will not work when #{bean.renderResult} defaults to false:

   <h:form id="form">
        <h:commandButton value="Submit" action="#{bean.toggleRenderResult}">
            <f:ajax render=":result" />
        </h:commandButton>
    </h:form>
    <h:outputText id="result" value="#{bean.result}" rendered="#{bean.renderResult}" />

You need to ensure that the render ID points to a component which is already present in the JSF-generated HTML output.

Following will work:

 <h:form id="form">
        <h:commandButton value="Submit" action="#{bean.toggleRenderResult}">
            <f:ajax render=":result" />
        </h:commandButton>
    </h:form>
    <h:panelGroup id="result">
        <h:outputText value="#{bean.result}" rendered="#{bean.renderResult}" />
    </h:panelGroup>

http://balusc.blogspot.in/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentWhichIsByItselfConditionallyRendered

Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202