Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JSF
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
JSF
rendered problem
lynn fann
Ranch Hand
Posts: 115
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I tried to do a render for outputText component, but i just can get it right. Below is the code that i wrote.
Bean class:
private HtmlOutputText outputText3; public SCBean() { checkUpgrade(); } public void checkUpgrade() { HtmlOutputText outputText3 = new HtmlOutputText(); int oSpeed = 1000; int nSpeed = 8000; if (oSpeed < nSpeed) { upgrade = true; outputText3.setRendered(true); System.out.println("upgrade true:"); }else{ outputText3.setRendered(false); System.out.println("upgrade false:"); } } public void setOutputText3(HtmlOutputText outputText3) { this.outputText3 = outputText3; } public HtmlOutputText getOutputText3() { return outputText3; }
jsp
page
<h:outputText value="You may experience temporary downtime" id="outputText3"/>
The text is always been shown even if i have set "outputText3.setRendered(false);"
Did i do set the rendering correctly? Where have i gone wrong.
Thanks.
Bauke Scholtz
Ranch Hand
Posts: 2458
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You didn't bind the outputtext to the backing bean. You can use the component's 'binding' attribute for this.
And
you should
be using the same instance and not creating a new instance inside the checkUpgrade() method.
lynn fann
Ranch Hand
Posts: 115
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i have set the binding attribute="#{SCBean.outputText3}" but it doesnt work.
If i remove the new instance. i have the following error:
javax.faces.FacesException: Can't instantiate class: 'view.backing.SCBean'.. class view.backing.SCBean : java.lang.NullPointerException
Bauke Scholtz
Ranch Hand
Posts: 2458
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Instantiate the property itself. Do not create a new one.
lynn fann
Ranch Hand
Posts: 115
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
sorry, how do it Instantiate the property itself? is it like this: HtmlOutputText outputText3; ?
Bauke Scholtz
Ranch Hand
Posts: 2458
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Just
private SomeObject someObject = new SomeObject();
or lazily
if (this.someObject == null) this.someObject = new SomeObject();
Point is that you should use the property as reference and not to create a new one which is not related to any property at any way.
lynn fann
Ranch Hand
Posts: 115
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
ok, it works now.
Thanks for your help
Bauke Scholtz
Ranch Hand
Posts: 2458
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You're welcome.
After some pecan pie, you might want to cleanse your palatte with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Problem with dynamic dataTable generation
Mail sending program
JTable inside JScrollPane - background coloring problem
Dynamic Richfaces Tab Creation In Java Code ..How To Handle Create Event/Action
JTable is not inserting the data
More...