You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Damar Thapa <th...@gmail.com> on 2008/01/04 17:44:36 UTC

c:if question

Hi,

I have the following snapshot:

<h:selectOneRadio id="myRadio" value="#{email.htmlOrText}" >
                    <f:selectItem itemValue="text" itemLabel="Text"/>
                    <f:selectItem itemValue="html" itemLabel="Html"/>
                     <a4j:support event="onchange" reRender="body" />
  </h:selectOneRadio>

<div id="body">
                <c:if test="{$email.htmlOrText = 'text'}">
                          <h:inputTextarea value="#{email.bodyEmail}"
cols="70" rows="15" />
                  </c:if>
                  <c:if test="{$email.htmlOrText = 'html'}">
                          <t:inputHtml value="#{email.bodyEmail}"
addKupuLogo="false"/>
                </c:if>
</div>

What I am trying to do is:  when the  value of  radio button is changed, it
should render "body" part, in which ther are two <c:ifs.

How can I force it to render the body part as the user changes the value of
oneselectRadio button?

Any pointers would be highly appreciated.

Thanks


With regards,
DT

Re: c:if question

Posted by Richard Yee <ri...@gmail.com>.
Is this a typo?

               <h:inputTextarea id="txt" value="#{email.bodyEmail}"
cols="70" rows="15" rendered="#{ email.htmlOrText == 'text'}" />
                 <t:inputHtml id="htm" value="#{email.bodyEmail}"
addKupuLogo="false" rendered="#{email.htmlOrText == 'text'}" />

You have 'rendered=#{email.htmlOrText == text}' on both

-Richard


On Jan 5, 2008 7:34 AM, Damar Thapa <th...@gmail.com> wrote:

> Hi,
>
> Thanks for your message.
>
> I am seeing a weird situation!
>
> The following snapshot works fine (can display the required output
> correctly!):
>
> <h:selectOneMenu id="htmlOrText" value="#{email.htmlOrText}" >
> >                     <f:selectItem itemValue="text" itemLabel="Text"/>
> >                     <f:selectItem itemValue="html" itemLabel="Html"/>
> >                     <a4j:support event="onchange"
> > reRender="txt,isTxt,isHtml" ajaxSingle="true"/>
> >                 </h:selectOneMenu>
> >
> >                 <h:outputText id="txtHtml" value="#{ email.htmlOrText}"/>
> >
> >
> >                    Text:
> >                   <h:outputText id="isTxt" value="#{email.htmlOrText ==
> > 'text'}"/>
> >
> >                   Html:
> >                   <h:outputText id="isHtml" value="#{email.htmlOrText ==
> > 'html'}"/>
> >
>
> But, when I try the following (ironically, the real code that I need!), it
> does not render:
>
> <h:selectOneMenu id="htmlOrText" value="#{email.htmlOrText}" >
> >                     <f:selectItem itemValue="text" itemLabel="Text"/>
> >                     <f:selectItem itemValue="html" itemLabel="Html"/>
> >                     <a4j:support event="onchange" reRender="txt, htm"
> > ajaxSingle="true"/>
> >                 </h:selectOneMenu>
> >
> >
> >                  <h:inputTextarea id="txt" value="#{email.bodyEmail}"
> > cols="70" rows="15" rendered="#{ email.htmlOrText == 'text'}" />
> >                  <t:inputHtml id="htm" value="#{email.bodyEmail}"
> > addKupuLogo="false" rendered="#{email.htmlOrText == 'text'}" />
> >
> >
>
> Any pointers on this?
> Thanks once again.
>
> With regards,
> DT
>
> On Jan 5, 2008 1:52 AM, simon <si...@chello.at> wrote:
>
> >
> > On Sat, 2008-01-05 at 00:44 +0800, Damar Thapa wrote:
> > > Hi,
> > >
> > > I have the following snapshot:
> > >
> > > <h:selectOneRadio id="myRadio" value="#{email.htmlOrText}" >
> > >                     <f:selectItem itemValue="text" itemLabel="Text"/>
> > >                     <f:selectItem itemValue="html" itemLabel="Html"/>
> > >                      <a4j:support event="onchange" reRender="body" />
> > >   </h:selectOneRadio>
> > >
> > > <div id="body">
> > >                 <c:if test="{$email.htmlOrText = 'text'}">
> > >                           <h:inputTextarea value="#{email.bodyEmail }"
> > > cols="70" rows="15" />
> > >                   </c:if>
> > >                   <c:if test="{$email.htmlOrText = 'html'}">
> > >                           <t:inputHtml value="#{ email.bodyEmail}"
> > > addKupuLogo="false"/>
> > >                 </c:if>
> > > </div>
> > >
> > > What I am trying to do is:  when the  value of  radio button is
> > > changed, it should render "body" part, in which ther are two <c:ifs.
> > >
> > > How can I force it to render the body part as the user changes the
> > > value of oneselectRadio button?
> >
> > Do not use c:if. Do this instead:
> >  <h:inputTextarea rendered="#{email.htmlOrText == 'text'}" .../>
> >  <h:inputHtml rendered="#{email.htmlOrText == 'html'}" .../>
> >
> > Regards,
> >
> > Simon
> >
> >
>
>
> --
> With regards,
>
> Damar Thapa, Hong Kong
> (http://damarsblog.blogspot.com)

Re: c:if question

Posted by Damar Thapa <th...@gmail.com>.
Hi,

Thanks for your message.

I am seeing a weird situation!

The following snapshot works fine (can display the required output
correctly!):

<h:selectOneMenu id="htmlOrText" value="#{email.htmlOrText}" >
>                     <f:selectItem itemValue="text" itemLabel="Text"/>
>                     <f:selectItem itemValue="html" itemLabel="Html"/>
>                     <a4j:support event="onchange"
> reRender="txt,isTxt,isHtml" ajaxSingle="true"/>
>                 </h:selectOneMenu>
>
>                 <h:outputText id="txtHtml" value="#{email.htmlOrText}"/>
>
>                    Text:
>                   <h:outputText id="isTxt" value="#{email.htmlOrText ==
> 'text'}"/>
>
>                   Html:
>                   <h:outputText id="isHtml" value="#{email.htmlOrText ==
> 'html'}"/>
>

But, when I try the following (ironically, the real code that I need!), it
does not render:

<h:selectOneMenu id="htmlOrText" value="#{email.htmlOrText}" >
>                     <f:selectItem itemValue="text" itemLabel="Text"/>
>                     <f:selectItem itemValue="html" itemLabel="Html"/>
>                     <a4j:support event="onchange" reRender="txt, htm"
> ajaxSingle="true"/>
>                 </h:selectOneMenu>
>
>
>                  <h:inputTextarea id="txt" value="#{email.bodyEmail}"
> cols="70" rows="15" rendered="#{email.htmlOrText == 'text'}" />
>                  <t:inputHtml id="htm" value="#{email.bodyEmail}"
> addKupuLogo="false" rendered="#{email.htmlOrText == 'text'}" />
>
>

Any pointers on this?
Thanks once again.

With regards,
DT
On Jan 5, 2008 1:52 AM, simon <si...@chello.at> wrote:

>
> On Sat, 2008-01-05 at 00:44 +0800, Damar Thapa wrote:
> > Hi,
> >
> > I have the following snapshot:
> >
> > <h:selectOneRadio id="myRadio" value="#{email.htmlOrText}" >
> >                     <f:selectItem itemValue="text" itemLabel="Text"/>
> >                     <f:selectItem itemValue="html" itemLabel="Html"/>
> >                      <a4j:support event="onchange" reRender="body" />
> >   </h:selectOneRadio>
> >
> > <div id="body">
> >                 <c:if test="{$email.htmlOrText = 'text'}">
> >                           <h:inputTextarea value="#{email.bodyEmail}"
> > cols="70" rows="15" />
> >                   </c:if>
> >                   <c:if test="{$email.htmlOrText = 'html'}">
> >                           <t:inputHtml value="#{email.bodyEmail}"
> > addKupuLogo="false"/>
> >                 </c:if>
> > </div>
> >
> > What I am trying to do is:  when the  value of  radio button is
> > changed, it should render "body" part, in which ther are two <c:ifs.
> >
> > How can I force it to render the body part as the user changes the
> > value of oneselectRadio button?
>
> Do not use c:if. Do this instead:
>  <h:inputTextarea rendered="#{email.htmlOrText == 'text'}" .../>
>  <h:inputHtml rendered="#{email.htmlOrText == 'html'}" .../>
>
> Regards,
>
> Simon
>
>


-- 
With regards,

Damar Thapa, Hong Kong
(http://damarsblog.blogspot.com)

Re: c:if question

Posted by simon <si...@chello.at>.
On Sat, 2008-01-05 at 00:44 +0800, Damar Thapa wrote:
> Hi,
> 
> I have the following snapshot:
> 
> <h:selectOneRadio id="myRadio" value="#{email.htmlOrText}" >
>                     <f:selectItem itemValue="text" itemLabel="Text"/> 
>                     <f:selectItem itemValue="html" itemLabel="Html"/>
>                      <a4j:support event="onchange" reRender="body" />
>   </h:selectOneRadio> 
>       
> <div id="body">         
>                 <c:if test="{$email.htmlOrText = 'text'}">
>                           <h:inputTextarea value="#{email.bodyEmail}"
> cols="70" rows="15" /> 
>                   </c:if>
>                   <c:if test="{$email.htmlOrText = 'html'}">
>                           <t:inputHtml value="#{email.bodyEmail}"
> addKupuLogo="false"/> 
>                 </c:if>
> </div>
> 
> What I am trying to do is:  when the  value of  radio button is
> changed, it should render "body" part, in which ther are two <c:ifs.
> 
> How can I force it to render the body part as the user changes the
> value of oneselectRadio button?

Do not use c:if. Do this instead:
  <h:inputTextarea rendered="#{email.htmlOrText == 'text'}" .../>
  <h:inputHtml rendered="#{email.htmlOrText == 'html'}" .../>

Regards,

Simon