Lógica Java: Creación del Managed Bean
IMPORTANTE:
Antes de continuar es importante tener claras las siguientes consideraciones:
- Se está trabajando con el servidor de despliegue Wildfly 10.0, este cuenta con las librerias y entorno necesario para funcionamiento del proyecto.
- Se está trabajando con la versión Neon de Eclipse con el Plugin JBossTool.
- Se debe haber creado previamente el proyecto siguiendo la entrada anterior.
Como lo mencioné vamos a manejar la relación entre la vista y la lógica java, para eso crearemos una clase que se conectará con nuestras páginas, este tipo de clases se les conocen como bean y consisten en una clase Pojo (Plain Old java Object) normal.
Para esto creamos en el directorio src de Java Resources una clase bean llamada “Saludo.java” a la cual le agregaremos la anotación @ManagedBean con un método que retornará un mensaje, de esta manera la clase bean permitirá hacer referencia directa a nuestra página retornando el mensaje definido al momento de ser invocado el método.
Nota: También podemos asignarle un nombre a nuestro bean así @ManagedBean (name="nombreClase") y de esta manera accedemos con #{nombreClase.mensaje} sin embargo para este ejemplo lo hacemos con el nombre de la clase en minúsculas.
Posteriormente modificamos nuestra página index.xhtml y agregamos un componente “outputText” al que le asociamos el llamado a nuestra clase bean y el método mensaje definido previamente.
Al componente h:outputText le enviamos #{saludo.mensaje} eso lo que va a hacer es enlazarse con la clase java, lo llamamos mediante el nombre de la clase (en minúscula), punto y la propiedad (variable o método al que queremos acceder).
Importante: En caso de que el sistema no reconozca el bean creado, se podría hacer clean al proyecto o reiniciar eclipse para limpiar referencias, en teoría el debería poder identificar el bean, sino esto podría deberse a errores al momento de crear el proyecto JSF o referencias al JDK y Servidor.
Al desplegar nuevamente el sistema veremos que la página index.xhtml presenta el mensaje definido en la clase bean.
Y listo, de esta forma vemos rápidamente como se hace la asociación de nuestra pagina con la clase java que retorna un mensaje de bienvenida al sistema!
En la próxima entrada continuaremos modificando el proyecto para vincularle un campo de texto que permita recibir y procesar información desde nuestro bean.
También te podría Interesar.
- Que es Java . Características y generalidades
- Introducción y Generalidades JEE
- Conceptos Básicos JEE
- Configuración Ambiente de Desarrollo
- Porqué JSF y no JSP y Servlets
- Ejemplo Eventos del Teclado en Java
- Que son los Patrones de Diseño ?
- Ejemplo Conectando Java con MySql
- Manejo de Excepciones en Java
- Conceptos Básicos de Programación Orientada a Objetos.
- ¿ String Vrs StringBuffer Vrs StringBuilder ?
- Comparando Fechas En Java
- Integración Continua, Primeros Pasos Con Jenkins
¿Hay algo que quieras anexar o comentar sobre esta entrada? no dudes en hacerlo.....y si te gustó, te invito a compartir y Suscribirte ingresando al botón "Participar en este sitio" para darte cuenta de mas entradas como esta ;)
podrias hacer algo de animacion usando hilos en java con interfaz grafica
ResponderEliminartendras algún ejemplo de DataView con primefaces jsf me interesa mucho saber, gracias
ResponderEliminarThis is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me..
ResponderEliminarRprogramming Training in annanagar
r-programming Training in marathahalli
r-programming Training in rajajinagar
r-programming Training in bangalore
Amazing Article ! I have bookmarked this article page as i received good information from this. All the best for the upcoming articles. I will be waiting for your new articles. Thank You ! Kindly Visit Us @ Coimbatore Travels | Ooty Travels | Coimbatore Airport Taxi
ResponderEliminarAmazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live. I have bookmarked more article from this website. Such a nice blog you are providing ! Kindly Visit Us @ Best Travels in Madurai | Tours and Travels in Madurai | Madurai Travels
ResponderEliminarThank you for excellent article.
ResponderEliminarPlease refer below if you are looking for best project center in coimbatore
final year projects in coimbatore
Spoken English Training in coimbatore
final year projects for CSE in coimbatore
final year projects for IT in coimbatore
final year projects for ECE in coimbatore
final year projects for EEE in coimbatore
final year projects for Mechanical in coimbatore
final year projects for Instrumentation in coimbatore
Information from this blog is very useful for me, am very happy to read this blog Kindly visit us @ Luxury Watch Box | Shoe Box Manufacturer | Candle Packaging Boxes
ResponderEliminarThanks For Sharing Your Information Please Keep UpDating Us Time Just Went On Reading The article The Information shared Is Very Helpful
ResponderEliminarDatascience Online Training Aws Online Training Python Online Training Devops Online Training
Are you looking for a maid for your home to care your baby,patient care taker, cook service or a japa maid for your pregnent wife we are allso providing maid to take care of your old parents.we are the best and cheapest service provider in delhi for more info visit our site and get all info.
ResponderEliminarmaid service provider in South Delhi
maid service provider in Dwarka
maid service provider in Gurgaon
maid service provider in Paschim Vihar
cook service provider in Paschim Vihar
cook service provider in Dwarka
cook service provider in south Delhi
baby care service provider in Delhi NCR
baby care service provider in Gurgaon
baby care service provider in Dwarka
baby service provider in south Delhi
servant service provider in Delhi NCR
servant service provider in Paschim Vihar
servant Service provider in South Delhi
japa maid service in Paschim Vihar
japa maid service in Delhi NCR
japa maid service in Dwarka
japa maid service in south Delhi
patient care service in Paschim Vihar
patient care service in Delhi NCR
patient care service in Dwarka
Patient care service in south Delhi
Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
ResponderEliminarIf you are looking for any Data science Related information please visit our website Data science courses in Pune page!
This is very informing and helpful. Thanks
ResponderEliminarinternship meaning | internship meaning in tamil | internship work from home | internship certificate format | internship for students | internship letter | Internship completion certificate | internship program | internship certificate online | internship graphic design
A very interesting blog....
ResponderEliminarups computer full form
kb full form
love full form
rpm full form
ide full form in computer
dtp full form
d v d full form
bca full form and subjects
swat full form
micr full form in computer
manaiyadi sasthiram tamil
ResponderEliminarfood for hair growth in tamil
moochu pidippu
badam benefits in tamil
உடல் எடை அதிகரிக்க
badam pisin benefits in tamil
dolo 650 uses in tamil
bay leaf in tamil
saibol cream uses in tamil
அதிமதுரம் பயன்கள்
ResponderEliminarIts Pleasure to read your blog.The above articles is very impressive, and I really enjoyed reading your blog and points that you expressed. I love to come back on a regular basis,post more on the subject.
summer training |
web design and development |
aws training |
cyber technology courses |
robotics coding course |
mba finance internship in gurgaon |
website design institute |
students database chennai |
full stack engineer intern |
php mysql training |