• 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

Using the rendered attribute nulls my value related backing bean variable.

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a Greenhorn to JSF and have been battling my way through learning how to use it and produce a Production product at the same time. I have been using JavaServerFaces IN Action by Kito D. Mann. Apparently I cannot right off find anything with more explanation than is found on page 148 (4.2 Common Component properties). Also, Google and Bing searchs bring up some information, but does not seem to addres my particular concern.


I am working with a series of comments of which I can have up to ten levels. The first level (0 based) is always displayed, but the other nine levels (1-9) I want to not be rendered as visible until that level is reached. The following is a snippet of code reflecting what I am attempting. The example has backing bean: level. The 'comment1' and 'name1' fields both have getters and setters in the 'level' backing bean.


<h:panelGrid columns="2" border="0" cellpadding="2" cellspacing="0" rendered="#{level.level >= 1}" >
<h:inputText id="comment1" value="#{level.coment1}" title="COMMENT ONE" readonly="#{level.level > 1}" />
<h:inputText id="name1" value="#{level.name1}" title="NAME ONE" readonly="#{level.level > 1}" />
</h:panelGrid>


This works great for not displaying this particular panelGrid when the level is 0. And the readonly works great for levels above 1 in this example. But when the level is 1 and the screen is submitted whatever has been entered on the screen in the 'comment1' and 'name1' fields is returned as 'null' instead of what has been entered for the comment and name.

What am I missing? What have I not learned yet? Can someone point me to an explanation on how to use this?


Thank you.

rdb
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this component embedded in a JSF form?
 
Richard Blaha
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tim, thank you for your response. Yes it is. I have quite a bit of other information prior to my comment section. To be accurate I have:

<h:form>
<%-- a lot of input information is collected here --%>
<h:panelGroup >
<%-- the code given in original post --%>
</h:panelGroup >

<h:commandLink action="#{level.edit}" value="Save">
<f:param name="jsfcrud.currentLevel" value="#{jsfcrud_class['com.company.jsf.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][level.level][level.converter].jsfcrud_invoke}"/>
</h:commandLink>
</h:form>

Also, in the original post if all I do is remove the rendered paramter I can retrieve the value without any problem.

I am using Netbeans 6.7.1 as my IDE for generating the initial JSF web pages/backing beans/etc.

rdb
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmmm. Is the scope of the "level" bean "request"? If so, try "session". Or, if you're using JSF2 "view".

Hint: you can make code and XML more readable if you use the message editor's "Code" button.
 
Richard Blaha
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the faces-config.xml the <managed-bean-scope> was set to 'session'. When I put in 'view' I received the following error from the Glassfish server:

Value 'view' is not facet-valid with respect to enumeration '[request, session, application, none]'. It must be a value from the enumeration.

rdb
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That means you don't have jsf2 support. Use session scope, instead.
 
Richard Blaha
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your direction so far. Where do I go from here? Sounds like a sticky wicket right now.
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Richard Blaha wrote:Thanks for your direction so far. Where do I go from here? Sounds like a sticky wicket right now.



For that you might want to talk to some local experts. Sometimes it's easier to tell when you can go "hands-on".
 
Richard Blaha
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer lies somewhere in my production code. I just wrote a quick webapp to test using a tutorial database table and the rendered parameter appears to work as described. Now to find the difference between my test code and my production code. Not sure where to look or what to look for.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic