diff --git a/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBean.java b/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBean.java
index 08b2a2a..7353c41 100644
--- a/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBean.java
+++ b/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBean.java
@@ -1,156 +1,155 @@
-/*
- * Demoiselle Framework
- * Copyright (C) 2010 SERPRO
- * ----------------------------------------------------------------------------
- * This file is part of Demoiselle Framework.
- *
- * Demoiselle Framework is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License version 3
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License version 3
- * along with this program; if not, see
- * or write to the Free Software Foundation, Inc., 51 Franklin Street,
- * Fifth Floor, Boston, MA 02110-1301, USA.
- * ----------------------------------------------------------------------------
- * Este arquivo é parte do Framework Demoiselle.
- *
- * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
- * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
- * do Software Livre (FSF).
- *
- * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
- * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
- * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
- * para maiores detalhes.
- *
- * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
- * "LICENCA.txt", junto com esse programa. Se não, acesse
- * ou escreva para a Fundação do Software Livre (FSF) Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
- */
-package br.gov.frameworkdemoiselle.template;
-
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.inject.Inject;
-
-import br.gov.frameworkdemoiselle.DemoiselleException;
-import br.gov.frameworkdemoiselle.annotation.Name;
-import br.gov.frameworkdemoiselle.util.Beans;
-import br.gov.frameworkdemoiselle.util.Parameter;
-import br.gov.frameworkdemoiselle.util.Reflections;
-import br.gov.frameworkdemoiselle.util.ResourceBundle;
-
-import com.sun.faces.util.Util;
-
-public abstract class AbstractEditPageBean extends AbstractPageBean implements EditPageBean {
-
- private static final long serialVersionUID = 1L;
-
- @Inject
- private Parameter id;
-
- private T bean;
-
- private Class beanClass;
-
- private Class idClass;
-
- @Inject
- @Name("demoiselle-jsf-bundle")
- private ResourceBundle bundle;
-
- @Inject
- private FacesContext facesContext;
-
- protected void clear() {
- this.id = null;
- this.bean = null;
- }
-
- protected T createBean() {
- return Beans.getReference(getBeanClass());
- }
-
- @Override
- public T getBean() {
- if (this.bean == null) {
- initBean();
- }
-
- return this.bean;
- }
-
- protected Class getBeanClass() {
- if (this.beanClass == null) {
- this.beanClass = Reflections.getGenericTypeArgument(this.getClass(), 0);
- }
-
- return this.beanClass;
- }
-
- protected Class getIdClass() {
- if (this.idClass == null) {
- this.idClass = Reflections.getGenericTypeArgument(this.getClass(), 1);
- }
-
- return this.idClass;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public I getId() {
- Converter converter = getIdConverter();
-
- if(converter == null && String.class.equals(getIdClass())) {
- return (I) id.getValue();
-
- } else if (converter == null) {
- throw new DemoiselleException(bundle.getString("id-converter-not-found", getIdClass().getCanonicalName()));
-
- } else {
- return (I) converter.getAsObject(facesContext, facesContext.getViewRoot(), id.getValue());
- }
- }
-
- private Converter getIdConverter() {
- return Util.getConverterForClass(getIdClass(), facesContext);
- }
-
- protected abstract void handleLoad();
-
- private void initBean() {
- if (isUpdateMode()) {
- this.bean = this.loadBean();
- } else {
- setBean(createBean());
- }
- }
-
- @Override
- public boolean isUpdateMode() {
- return getId() != null;
- }
-
- private T loadBean() {
- this.handleLoad();
- return this.bean;
- }
-
- protected void setBean(final T bean) {
- this.bean = bean;
- }
-
- // protected void setId(final I id) {
- // clear();
- // String value = getIdConverter().getAsString(getFacesContext(), getFacesContext().getViewRoot(), id);
- // this.id.setValue(value);
- // }
-
-}
+/*
+ * Demoiselle Framework
+ * Copyright (C) 2010 SERPRO
+ * ----------------------------------------------------------------------------
+ * This file is part of Demoiselle Framework.
+ *
+ * Demoiselle Framework is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License version 3
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License version 3
+ * along with this program; if not, see
+ * or write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301, USA.
+ * ----------------------------------------------------------------------------
+ * Este arquivo é parte do Framework Demoiselle.
+ *
+ * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
+ * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
+ * do Software Livre (FSF).
+ *
+ * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
+ * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
+ * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
+ * para maiores detalhes.
+ *
+ * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
+ * "LICENCA.txt", junto com esse programa. Se não, acesse
+ * ou escreva para a Fundação do Software Livre (FSF) Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
+ */
+package br.gov.frameworkdemoiselle.template;
+
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.inject.Inject;
+
+import br.gov.frameworkdemoiselle.DemoiselleException;
+import br.gov.frameworkdemoiselle.annotation.Name;
+import br.gov.frameworkdemoiselle.util.Beans;
+import br.gov.frameworkdemoiselle.util.Faces;
+import br.gov.frameworkdemoiselle.util.Parameter;
+import br.gov.frameworkdemoiselle.util.Reflections;
+import br.gov.frameworkdemoiselle.util.ResourceBundle;
+
+public abstract class AbstractEditPageBean extends AbstractPageBean implements EditPageBean {
+
+ private static final long serialVersionUID = 1L;
+
+ @Inject
+ private Parameter id;
+
+ private T bean;
+
+ private Class beanClass;
+
+ private Class idClass;
+
+ @Inject
+ @Name("demoiselle-jsf-bundle")
+ private ResourceBundle bundle;
+
+ @Inject
+ private FacesContext facesContext;
+
+ protected void clear() {
+ this.id = null;
+ this.bean = null;
+ }
+
+ protected T createBean() {
+ return Beans.getReference(getBeanClass());
+ }
+
+ @Override
+ public T getBean() {
+ if (this.bean == null) {
+ initBean();
+ }
+
+ return this.bean;
+ }
+
+ protected Class getBeanClass() {
+ if (this.beanClass == null) {
+ this.beanClass = Reflections.getGenericTypeArgument(this.getClass(), 0);
+ }
+
+ return this.beanClass;
+ }
+
+ protected Class getIdClass() {
+ if (this.idClass == null) {
+ this.idClass = Reflections.getGenericTypeArgument(this.getClass(), 1);
+ }
+
+ return this.idClass;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public I getId() {
+ Converter converter = getIdConverter();
+
+ if(converter == null && String.class.equals(getIdClass())) {
+ return (I) id.getValue();
+
+ } else if (converter == null) {
+ throw new DemoiselleException(bundle.getString("id-converter-not-found", getIdClass().getCanonicalName()));
+
+ } else {
+ return (I) converter.getAsObject(facesContext, facesContext.getViewRoot(), id.getValue());
+ }
+ }
+
+ private Converter getIdConverter() {
+ return Faces.getConverter(getIdClass());
+ }
+
+ protected abstract void handleLoad();
+
+ private void initBean() {
+ if (isUpdateMode()) {
+ this.bean = this.loadBean();
+ } else {
+ setBean(createBean());
+ }
+ }
+
+ @Override
+ public boolean isUpdateMode() {
+ return getId() != null;
+ }
+
+ private T loadBean() {
+ this.handleLoad();
+ return this.bean;
+ }
+
+ protected void setBean(final T bean) {
+ this.bean = bean;
+ }
+
+ // protected void setId(final I id) {
+ // clear();
+ // String value = getIdConverter().getAsString(getFacesContext(), getFacesContext().getViewRoot(), id);
+ // this.id.setValue(value);
+ // }
+
+}
diff --git a/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/util/Faces.java b/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/util/Faces.java
index c34fa5d..d408c9e 100644
--- a/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/util/Faces.java
+++ b/impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/util/Faces.java
@@ -1,158 +1,167 @@
-/*
- * Demoiselle Framework
- * Copyright (C) 2010 SERPRO
- * ----------------------------------------------------------------------------
- * This file is part of Demoiselle Framework.
- *
- * Demoiselle Framework is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License version 3
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License version 3
- * along with this program; if not, see
- * or write to the Free Software Foundation, Inc., 51 Franklin Street,
- * Fifth Floor, Boston, MA 02110-1301, USA.
- * ----------------------------------------------------------------------------
- * Este arquivo é parte do Framework Demoiselle.
- *
- * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
- * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
- * do Software Livre (FSF).
- *
- * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
- * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
- * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
- * para maiores detalhes.
- *
- * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
- * "LICENCA.txt", junto com esse programa. Se não, acesse
- * ou escreva para a Fundação do Software Livre (FSF) Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
- */
-package br.gov.frameworkdemoiselle.util;
-
-import static javax.faces.application.FacesMessage.SEVERITY_ERROR;
-import static javax.faces.application.FacesMessage.SEVERITY_FATAL;
-import static javax.faces.application.FacesMessage.SEVERITY_INFO;
-import static javax.faces.application.FacesMessage.SEVERITY_WARN;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.application.FacesMessage.Severity;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import br.gov.frameworkdemoiselle.exception.ApplicationException;
-import br.gov.frameworkdemoiselle.message.Message;
-import br.gov.frameworkdemoiselle.message.SeverityType;
-
-import com.sun.faces.util.Util;
-
-public class Faces {
-
- public static void addMessages(final List messages) {
- if (messages != null) {
- for (Message m : messages) {
- addMessage(m);
- }
- }
- }
-
- public static void addMessage(final Message message) {
- getFacesContext().addMessage(null, parse(message));
- }
-
- public static void addMessage(final String clientId, final Message message) {
- getFacesContext().addMessage(clientId, parse(message));
- }
-
- public static void addMessage(final String clientId, final Throwable throwable) {
- getFacesContext().addMessage(clientId, parse(throwable));
- }
-
- public static void addMessage(final Throwable throwable) {
- addMessage(null, throwable);
- }
-
- private static FacesContext getFacesContext() {
- return Beans.getReference(FacesContext.class);
- }
-
- public static Severity parse(final SeverityType severityType) {
- Severity result = null;
-
- switch (severityType) {
- case INFO:
- result = SEVERITY_INFO;
- break;
- case WARN:
- result = SEVERITY_WARN;
- break;
- case ERROR:
- result = SEVERITY_ERROR;
- break;
- case FATAL:
- result = SEVERITY_FATAL;
- }
-
- return result;
- }
-
- public static FacesMessage parse(final Throwable throwable) {
- FacesMessage facesMessage = new FacesMessage();
- ApplicationException annotation = throwable.getClass().getAnnotation(ApplicationException.class);
-
- if (annotation != null) {
- facesMessage.setSeverity(parse(annotation.severity()));
- } else {
- facesMessage.setSeverity(SEVERITY_ERROR);
- }
-
- if (throwable.getMessage() != null) {
- facesMessage.setSummary(throwable.getMessage());
- } else {
- facesMessage.setSummary(throwable.toString());
- }
-
- return facesMessage;
- }
-
- public static FacesMessage parse(final Message message) {
- FacesMessage facesMessage = new FacesMessage();
- facesMessage.setSeverity(parse(message.getSeverity()));
- facesMessage.setSummary(message.getText());
- return facesMessage;
- }
-
- public static Object convert(final String value, final Converter converter) {
- Object result = null;
-
- if (!Strings.isEmpty(value)) {
- if (converter != null) {
- result = converter.getAsObject(getFacesContext(), getFacesContext().getViewRoot(), value);
- } else {
- result = new String(value);
- }
- }
-
- return result;
- }
-
- public static Converter getConverter(Class> clazz) {
- return Util.getConverterForClass(clazz, getFacesContext());
- }
-
- public static Map getViewMap() {
- UIViewRoot viewRoot = getFacesContext().getViewRoot();
- return viewRoot.getViewMap(true);
- }
-
-}
+/*
+ * Demoiselle Framework
+ * Copyright (C) 2010 SERPRO
+ * ----------------------------------------------------------------------------
+ * This file is part of Demoiselle Framework.
+ *
+ * Demoiselle Framework is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License version 3
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License version 3
+ * along with this program; if not, see
+ * or write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301, USA.
+ * ----------------------------------------------------------------------------
+ * Este arquivo é parte do Framework Demoiselle.
+ *
+ * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
+ * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
+ * do Software Livre (FSF).
+ *
+ * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
+ * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
+ * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
+ * para maiores detalhes.
+ *
+ * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
+ * "LICENCA.txt", junto com esse programa. Se não, acesse
+ * ou escreva para a Fundação do Software Livre (FSF) Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
+ */
+package br.gov.frameworkdemoiselle.util;
+
+import static javax.faces.application.FacesMessage.SEVERITY_ERROR;
+import static javax.faces.application.FacesMessage.SEVERITY_FATAL;
+import static javax.faces.application.FacesMessage.SEVERITY_INFO;
+import static javax.faces.application.FacesMessage.SEVERITY_WARN;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import br.gov.frameworkdemoiselle.exception.ApplicationException;
+import br.gov.frameworkdemoiselle.message.Message;
+import br.gov.frameworkdemoiselle.message.SeverityType;
+
+public class Faces {
+
+ public static void addMessages(final List messages) {
+ if (messages != null) {
+ for (Message m : messages) {
+ addMessage(m);
+ }
+ }
+ }
+
+ public static void addMessage(final Message message) {
+ getFacesContext().addMessage(null, parse(message));
+ }
+
+ public static void addMessage(final String clientId, final Message message) {
+ getFacesContext().addMessage(clientId, parse(message));
+ }
+
+ public static void addMessage(final String clientId, final Throwable throwable) {
+ getFacesContext().addMessage(clientId, parse(throwable));
+ }
+
+ public static void addMessage(final Throwable throwable) {
+ addMessage(null, throwable);
+ }
+
+ private static FacesContext getFacesContext() {
+ return Beans.getReference(FacesContext.class);
+ }
+
+ public static Severity parse(final SeverityType severityType) {
+ Severity result = null;
+
+ switch (severityType) {
+ case INFO:
+ result = SEVERITY_INFO;
+ break;
+ case WARN:
+ result = SEVERITY_WARN;
+ break;
+ case ERROR:
+ result = SEVERITY_ERROR;
+ break;
+ case FATAL:
+ result = SEVERITY_FATAL;
+ }
+
+ return result;
+ }
+
+ public static FacesMessage parse(final Throwable throwable) {
+ FacesMessage facesMessage = new FacesMessage();
+ ApplicationException annotation = throwable.getClass().getAnnotation(ApplicationException.class);
+
+ if (annotation != null) {
+ facesMessage.setSeverity(parse(annotation.severity()));
+ } else {
+ facesMessage.setSeverity(SEVERITY_ERROR);
+ }
+
+ if (throwable.getMessage() != null) {
+ facesMessage.setSummary(throwable.getMessage());
+ } else {
+ facesMessage.setSummary(throwable.toString());
+ }
+
+ return facesMessage;
+ }
+
+ public static FacesMessage parse(final Message message) {
+ FacesMessage facesMessage = new FacesMessage();
+ facesMessage.setSeverity(parse(message.getSeverity()));
+ facesMessage.setSummary(message.getText());
+ return facesMessage;
+ }
+
+ public static Object convert(final String value, final Converter converter) {
+ Object result = null;
+
+ if (!Strings.isEmpty(value)) {
+ if (converter != null) {
+ result = converter.getAsObject(getFacesContext(), getFacesContext().getViewRoot(), value);
+ } else {
+ result = new String(value);
+ }
+ }
+
+ return result;
+ }
+
+ public static Converter getConverter(Class> clazz) {
+ FacesContext context = getFacesContext();
+ if (clazz == null) {
+ return null;
+ }
+ try {
+ Application application = context.getApplication();
+ Converter converter = (application.createConverter(clazz));
+ return converter;
+ } catch (Exception e) {
+ return (null);
+ }
+ }
+
+ public static Map getViewMap() {
+ UIViewRoot viewRoot = getFacesContext().getViewRoot();
+ return viewRoot.getViewMap(true);
+ }
+
+}
--
libgit2 0.21.2