• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Value doesnt return when I use @Named annotation in JSF2 but @ManagedBean working fine.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I did a simple button action. It returns value whatever the user type in a texbox. But when I use @Named annotation, it returns nothing and also no error occurs. After I change "Named" to "ManagedBean" , everything working fine. I have configured everything that the http://www.theserverside.com/tutorial/Working-with-CDI-and-JSF-20-on-Tomcat-7-Configuring-Weld says but I couldnt understand the error because there is no error anywhere.

I am using JSF2 - Tomcat7

Thanks in advance.
 
Saloon Keeper
Posts: 28067
198
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
Welcome to the JavaRanch, Baris!

JSF ignores a lot of "errors" and one of them is when you don't have your resources named and defined properly.

The @Named annotation doesn't register the named object as a JSF managed bean (as far as I know, anyway). And if it doesn't, then JSF can't use it.
 
Baris Vlgl
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if so how do I know what causes this strange behavior without seeing any error ? Any resource that you can advice me to make a start. I am new to jsf.
 
Tim Holloway
Saloon Keeper
Posts: 28067
198
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
Unfortunately, there's no diagnostic information available. Sometimes you'll get a "property x not defined on bean y" type of message, but that's usually in cases where lack of a value is fatal. Otherwise, when data just simply fails to show, do the following checklist:

1. Make sure that the bean itself is defined and cataloged as a managed bean and that you have capitalized everything properly. The class name for the bean should begin with an uppercase letter and the actual bean reference (instance name) should begin with a lower-case letter. The @ManagedBean annotation will automatically take care of that, if that's what you are using.

2. Make sure that there's a public "getXxxx" method defined for the referenced property name "xxxx" and that it doesn't return void. Depending on the usage, it may be necessary to also define a public void "setXxxx" method as well.

3. Make sure that "getXxxx" actually is returning a non-blank value if you want a value to display!
 
Baris Vlgl
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for taking the time. Just one more question, could you explain what do you mean by "The @Named annotation doesn't register the named object as a JSF managed bean". I got confused about that.

 
Greenhorn
Posts: 12
Netbeans IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your bean session scoped?

If so, you must import the 'javax.enterprise.context' package for the @SessionScope annotation and not the 'javax.faces.bean' package as you would do if you were using a Managed Bean.

Well, i'm a rookie myself, so i'm not sure if this is the answer to your problem.
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic