Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to call a method in session bean from JSF (xhtml) page.

Reply
Thread Tools

How to call a method in session bean from JSF (xhtml) page.

 
 
Johnson Scaria John
Guest
Posts: n/a
 
      06-30-2008
How to call a method in session bean from JSF (xhtml) page.

JSF

<h:commandButton type="submit" value="Register"
action="#{register12.register()}"/>

SESSION BEAN

package org.domain.FinalSeam.session;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.domain.FinalSeam.entity.User;
import org.hibernate.validator.Valid;
import org.jboss.seam.annotations.IfInvalid;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Outcome;
import org.jboss.seam.log.Log;
import org.jboss.seam.core.FacesMessages;
@Stateless
@Name("register12")
public class RegisterActionBean implements Register
{
@In
@Valid
private User user;

@PersistenceContext
private EntityManager em;

@IfInvalid(outcome=Outcome.REDISPLAY)
public String
register()
{
List existing = em.createQuery("select username from
User where
username=:username")
.setParameter("username", user.getUsername())
.getResultList();

if (existing.size()==0)
{
em.persist(user);
return
"success";
}
else
{
FacesMessages.instance().add("User #{user.username}
already
exists");
return null;
}
}

}

But it show some error "register12" is not bound"

Is it correct way or need to modify some xml/file

I expecting a big hand from all

Thanks in advance
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Accessing value of a session bean on a JSF page laredotornado Java 4 07-10-2008 07:31 PM
Destroy JSF Bean on Session Timeout puneet.bansal@wipro.com Java 0 07-04-2007 05:32 PM
EJB Transaction (Session Bean - Entitiy Bean) X3 Java 0 10-01-2004 07:41 AM
can a session bean return a local entity bean object? David Thielen Java 2 09-12-2003 07:45 AM



Advertisments