Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Binding: converting from String to Object

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody:

I found myself having hard times using JSF...but I'll keep on trying and I need help.

I want to show a message from a backing bean called AuthenticationBean :

And the associate view I have:


But I got the following error from Tomcat: "javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalArgumentException: No puedo convertir javax.faces.component.html.HtmlOutputText@a65760 desde tipo class java.lang.String a class javax.faces.component.UIComponent"

The question is: Do I have to convert the String message to outputText? How can I do it? Is there anything I doing wrong?

Thanks in advance.
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to display message then it should be

<h: outputText id="message" styleClass="errores" value="#{AuthenticationBean.message}"/>

 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Smitha H Rao:

I use

binding="#{AuthenticationBean.message}"/>

because value works fine when getting data from the view (JSP). But in my case I need to update the message in the backing bean when the authentication failed and show it (update)in the same page (login.jsp).

There is a good example at Roseindia componenetInstanceBinding tutorial... but they use a different page when the authentication failed... I use the same login page where the initial message is empty.

I have in AuthenticationBean:

In the faces-config.xml :

Please, where is "the missing link"...I don't know how to solve this dummy problem... what I should do in the backing bean to call the setMessage method and change the message?

Thanks in advanced for your help.
 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am keeping on trying binding vs. value

I read in the book JSP, JSF, and Tomcat Web Development by Guilic Zambon

...The different is that with binding you establish a two-way link, which lets your backing modify the value of the field, while with value, the backing bean cannot modify the data entered by the user



I feel that's what I need but no success...



And in the AutenticacionBean:

The setter/getter methods and



But it doesn't work...still need your help.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All binding does is cause the component to be related to a bean method of set and get and others if they are there (at least set and get will) so


 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Samuel, thank you very much for your kind and excellent reply. You gave me the solution to casting a String to HtmlOutputText object.

I'm a newbie in JSP, JFS and the learning way is hard... Jim Rohn said:

How long should you try? Until!



Once again thanks a lot.
 
Samuel March
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All binding does is cause the component to be related to a bean method of set and get and others if they are there (at least set and get will) so

I had written this better last night but my browser crashed. The binding method supplied to the component in the binding=
must match the exact type of UIComponent(method return type - and - markup component to be exactly the same)
except when you are operating on it with API methods of its direct superclasses such as UIComponent , UIComponentBase , UIOutput and directly implemented interfaces for the java class type.

Look at the top of this page:
http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/api/javax/faces/component/html/HtmlOutputText.html

JSF API DOCS: http://java.sun.com/javaee/javaserverfaces/1.2_MR1/docs/api/index.html

 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic