You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Thomas Chang <th...@yahoo.de> on 2007/01/23 10:19:10 UTC
Question about using "rendered"
Hi all,
I use the rendered inoder to change the showing or hiding of an inputTextField in run-time. My code look as follow:
...
...
<h:inputText id="search_item2"
value="#{myBean.searchitem2}" size="30"
rendered="#{myBean.searchLabel == 2}" />
...
...
public class MyBean{
...
private String searchitem2 = null;
...
public String getSearchitem2(){
...
}
public void setSearchitem2{
...
}
...
}
But it works not so well. Exactly to say: The inputTextField can be shown or hidden in run time. But I can't get the value from the inputTextField.
But if I remove the "rendererd", I can get the value but the inputTextField can not be shown or hidden in run-time.
Who can tells me what's wrong?
Thomas
---------------------------------
Yahoo! 360° Bloggen und Leute treffen. Erstellen Sie jetzt Ihre eigene Seite kostenlos!.
Re: Question about using "rendered"
Posted by Thomas Chang <th...@yahoo.de>.
Hi Simon,
Thanks for the answer. I've solved my problem. I changed the backing bean from "request" to "session" in the faceconfig.xml. It runs.
Thanks again.
Thomas
Simon Kitching <si...@rhe.co.nz> schrieb:
Thomas Chang wrote:
> Hi all,
>
> I use the rendered inoder to change the showing or hiding of an
> inputTextField in run-time. My code look as follow:
>
> ...
> ...
> > value="#{myBean.searchitem2}" size="30"
> rendered="#{myBean.searchLabel == 2}" />
> ...
> ...
> public class MyBean{
> ...
> private String searchitem2 = null;
> ...
> public String getSearchitem2(){
> ...
> }
>
> public void setSearchitem2{
> ...
> }
> ...
> }
>
> But it works not so well. Exactly to say: The inputTextField can be
> shown or hidden in run time. But I can't get the value from the
> inputTextField.
>
> But if I remove the "rendererd", I can get the value but the
> inputTextField can not be shown or hidden in run-time.
>
> Who can tells me what's wrong?
I think you have a misunderstanding about the "rendered" attribute.
Setting this to false does not "make the component invisible in the
rendered html", it does not output the component into the html at all.
If you just want the field to become invisible to the user, but actually
be present in the page, then I suggest either:
(1)
value="#{myBean.searchitem2"
rendered="#{mybean.searchLabel == 2}"/>
value="#{myBean.searchitem2}"
rendered="#{mybean.searchLabel != 2}"/>
which ensures that if the inputText is not rendered, then a hidden field
is generated instead that contains the same value
or
(2)
style="#{myBean.searchitem2Style}"/>
where method getSearchitem2Style returns "display:hidden" if the input
should not be visible.
Regards,
Simon
---------------------------------
Was ist Glück? Schlafen Fische überhaupt? Die Antworten gibts auf Yahoo! Clever.
Re: Question about using "rendered"
Posted by Simon Kitching <si...@rhe.co.nz>.
Thomas Chang wrote:
> Hi all,
>
> I use the rendered inoder to change the showing or hiding of an
> inputTextField in run-time. My code look as follow:
>
> ...
> ...
> <h:inputText id="search_item2"
> value="#{myBean.searchitem2}" size="30"
> rendered="#{myBean.searchLabel == 2}" />
> ...
> ...
> public class MyBean{
> ...
> private String searchitem2 = null;
> ...
> public String getSearchitem2(){
> ...
> }
>
> public void setSearchitem2{
> ...
> }
> ...
> }
>
> But it works not so well. Exactly to say: The inputTextField can be
> shown or hidden in run time. But I can't get the value from the
> inputTextField.
>
> But if I remove the "rendererd", I can get the value but the
> inputTextField can not be shown or hidden in run-time.
>
> Who can tells me what's wrong?
I think you have a misunderstanding about the "rendered" attribute.
Setting this to false does not "make the component invisible in the
rendered html", it does not output the component into the html at all.
If you just want the field to become invisible to the user, but actually
be present in the page, then I suggest either:
(1)
<h:inputText id="search_item2"
value="#{myBean.searchitem2"
rendered="#{mybean.searchLabel == 2}"/>
<h:inputHidden id="search_item2_hidden"
value="#{myBean.searchitem2}"
rendered="#{mybean.searchLabel != 2}"/>
which ensures that if the inputText is not rendered, then a hidden field
is generated instead that contains the same value
or
(2)
<h:inputText id="search_item2" value="#{myBean.searchitem2}"
style="#{myBean.searchitem2Style}"/>
where method getSearchitem2Style returns "display:hidden" if the input
should not be visible.
Regards,
Simon
Re: Question about using "rendered"
Posted by Volker Weber <v....@inexso.de>.
Hi Thomas,
what exact did you mean by 'I can't get value from the inputTextField.'?
how did you try, in which phase, how did you switch the value of searchLabel?
You give not enough information to identfy your problem.
Regards,
Volker
2007/1/23, Thomas Chang <th...@yahoo.de>:
> HI,
>
> I have the getter and setter for myBean.searchLabel, otherwise the
> inputTextField would not change from shown and hidden in run-time. My
> problem is: if I use the rendererd, I can't get value from the
> inputTextField. I am quite wonder. :-(
>
> Here is my code again:
> <h:inputText id="search_item2"
> value="#{myBean.searchitem2}" size="30"
> rendered="#{myBean.searchLabel == 2}" />
>
> Thanks.
>
> Thomas
>
>
> Mr Arvind Pandey <ar...@yahoo.co.in> schrieb:
> Hi
> It seems as if there is no getter and setter for
> myBean.searchLabel which has been used in rendered
> attribute. Also you want it to be shown only if
> myBean.searchLabel is two '2' . so accordingly as per
> your logic you set myBean.searchLabel to 2.
>
> regards....
> Arvind
>
> --- Thomas Chang wrote:
>
> > Hi all,
> >
> > I use the rendered inoder to change the showing or
> > hiding of an inputTextField in run-time. My code
> > look as follow:
> >
> > ...
> > ...
> >
> > value="#{myBean.searchitem2}" size="30"
> > rendered="#{myBean.searchLabel == 2}" />
> > ...
> > ...
> > public class MyBean{
> > ...
> > private String searchitem2 = null;
> > ...
> > public String getSearchitem2(){
> > ...
> > }
> >
> > public void setSearchitem2{
> > ...
> > }
> > ...
> > }
> >
> > But it works not so well. Exactly to say: The
> > inputTextField can be shown or hidden in run time.
> > But I can't get the value from the inputTextField.
> >
> > But if I remove the "rendererd", I can get the value
> > but the inputTextField can not be shown or hidden in
> > run-time.
> >
> > Who can tells me what's wrong?
> >
> > Thomas
> >
> >
> >
> > ---------------------------------
> > Yahoo! 360° – Bloggen und Leute treffen. Erstellen
> > Sie jetzt Ihre eigene Seite – kostenlos!.
>
>
>
>
> __________________________________________________________
> Yahoo! India Answers: Share what you know. Learn something new
> http://in.answers.yahoo.com/
>
>
>
> ________________________________
> Was ist Glück? Schlafen Fische überhaupt? Die Antworten gibt's auf Yahoo!
> Clever.
>
>
Re: Question about using "rendered"
Posted by Thomas Chang <th...@yahoo.de>.
HI,
I have the getter and setter for myBean.searchLabel, otherwise the inputTextField would not change from shown and hidden in run-time. My problem is: if I use the rendererd, I can't get value from the inputTextField. I am quite wonder. :-(
Here is my code again:
<h:inputText id="search_item2"
value="#{myBean.searchitem2}" size="30"
rendered="#{myBean.searchLabel == 2}" />
Thanks.
Thomas
Mr Arvind Pandey <ar...@yahoo.co.in> schrieb: Hi
It seems as if there is no getter and setter for
myBean.searchLabel which has been used in rendered
attribute. Also you want it to be shown only if
myBean.searchLabel is two '2' . so accordingly as per
your logic you set myBean.searchLabel to 2.
regards....
Arvind
--- Thomas Chang wrote:
> Hi all,
>
> I use the rendered inoder to change the showing or
> hiding of an inputTextField in run-time. My code
> look as follow:
>
> ...
> ...
>
> value="#{myBean.searchitem2}" size="30"
> rendered="#{myBean.searchLabel == 2}" />
> ...
> ...
> public class MyBean{
> ...
> private String searchitem2 = null;
> ...
> public String getSearchitem2(){
> ...
> }
>
> public void setSearchitem2{
> ...
> }
> ...
> }
>
> But it works not so well. Exactly to say: The
> inputTextField can be shown or hidden in run time.
> But I can't get the value from the inputTextField.
>
> But if I remove the "rendererd", I can get the value
> but the inputTextField can not be shown or hidden in
> run-time.
>
> Who can tells me what's wrong?
>
> Thomas
>
>
>
> ---------------------------------
> Yahoo! 360° Bloggen und Leute treffen. Erstellen
> Sie jetzt Ihre eigene Seite kostenlos!.
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/
---------------------------------
Was ist Glück? Schlafen Fische überhaupt? Die Antworten gibts auf Yahoo! Clever.
Re: Question about using "rendered"
Posted by Mr Arvind Pandey <ar...@yahoo.co.in>.
Hi
It seems as if there is no getter and setter for
myBean.searchLabel which has been used in rendered
attribute. Also you want it to be shown only if
myBean.searchLabel is two '2' . so accordingly as per
your logic you set myBean.searchLabel to 2.
regards....
Arvind
--- Thomas Chang <th...@yahoo.de> wrote:
> Hi all,
>
> I use the rendered inoder to change the showing or
> hiding of an inputTextField in run-time. My code
> look as follow:
>
> ...
> ...
> <h:inputText id="search_item2"
> value="#{myBean.searchitem2}" size="30"
> rendered="#{myBean.searchLabel == 2}" />
> ...
> ...
> public class MyBean{
> ...
> private String searchitem2 = null;
> ...
> public String getSearchitem2(){
> ...
> }
>
> public void setSearchitem2{
> ...
> }
> ...
> }
>
> But it works not so well. Exactly to say: The
> inputTextField can be shown or hidden in run time.
> But I can't get the value from the inputTextField.
>
> But if I remove the "rendererd", I can get the value
> but the inputTextField can not be shown or hidden in
> run-time.
>
> Who can tells me what's wrong?
>
> Thomas
>
>
>
> ---------------------------------
> Yahoo! 360° Bloggen und Leute treffen. Erstellen
> Sie jetzt Ihre eigene Seite kostenlos!.
__________________________________________________________
Yahoo! India Answers: Share what you know. Learn something new
http://in.answers.yahoo.com/