From: Roland Haeder Date: Tue, 13 Oct 2015 11:51:01 +0000 (+0200) Subject: try to get through @EJB? X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b4200e8ab290b42806d0972ef546e94ec183de49;p=jbonuscard-lib.git try to get through @EJB? Signed-off-by:Roland Häder --- diff --git a/src/org/mxchange/addressbook/validator/addressbook/AddressbookIdValidator.java b/src/org/mxchange/addressbook/validator/addressbook/AddressbookIdValidator.java index c86a8fd..2b97044 100644 --- a/src/org/mxchange/addressbook/validator/addressbook/AddressbookIdValidator.java +++ b/src/org/mxchange/addressbook/validator/addressbook/AddressbookIdValidator.java @@ -17,15 +17,12 @@ package org.mxchange.addressbook.validator.addressbook; import java.text.MessageFormat; +import javax.ejb.EJB; import javax.faces.application.FacesMessage; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.validator.FacesValidator; import javax.faces.validator.ValidatorException; -import javax.faces.view.facelets.FaceletException; -import javax.naming.Context; -import javax.naming.InitialContext; -import javax.naming.NamingException; import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote; import org.mxchange.jcoreee.validator.number.BaseLongValidator; @@ -45,25 +42,9 @@ public class AddressbookIdValidator extends BaseLongValidator { /** * Remote bean */ + @EJB (mappedName = "ejb/stateless-addressbook") private AddressbookSessionBeanRemote addressbookBean; - /** - * Default constructor - */ - public AddressbookIdValidator () { - // Try it - try { - // Get context - Context context = new InitialContext(); - - // Try to to lookup the bean - this.addressbookBean = (AddressbookSessionBeanRemote) context.lookup("ejb/stateless-addressbook"); - } catch (final NamingException ex) { - // Throw again - throw new FaceletException(ex); - } - } - @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { // Trace message @@ -78,7 +59,7 @@ public class AddressbookIdValidator extends BaseLongValidator { // Is the address book id valid? if (!this.addressbookBean.isAddressbookIdUsed((Long) value)) { // Is not valid - throw new ValidatorException(new FacesMessage(MessageFormat.format("No address book found with id {0}. Please check your link.", value))); + throw new ValidatorException(new FacesMessage(MessageFormat.format("No address book found with id {0}. Please check your link.", value))); //NOI18N } // Trace message diff --git a/src/org/mxchange/addressbook/validator/names/AddressbookNameValidator.java b/src/org/mxchange/addressbook/validator/names/AddressbookNameValidator.java index b9a3b54..1e43b90 100644 --- a/src/org/mxchange/addressbook/validator/names/AddressbookNameValidator.java +++ b/src/org/mxchange/addressbook/validator/names/AddressbookNameValidator.java @@ -18,6 +18,7 @@ package org.mxchange.addressbook.validator.names; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; +import javax.faces.validator.FacesValidator; import javax.faces.validator.Validator; import javax.faces.validator.ValidatorException; import org.mxchange.jcoreee.validator.string.BaseStringValidator; @@ -27,6 +28,7 @@ import org.mxchange.jcoreee.validator.string.BaseStringValidator; *

* @author Roland Haeder */ +@FacesValidator (value = "AddressbookNameValidator") public class AddressbookNameValidator extends BaseStringValidator implements Validator { /**