Commit c5d566d33d940be2a3d4fa6cc7526cc41641f8e6
1 parent
34ce10e5
Exists in
master
[FWK-237] - Locais onde a extensão injeta diretamente uma instância de
FacesContext foram substituidos pelo uso de Beans.getInstance dentro dos métodos que precisam dessa instância.
Showing
3 changed files
with
4 additions
and
16 deletions
Show diff stats
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractEditPageBean.java
| @@ -75,9 +75,6 @@ public abstract class AbstractEditPageBean<T, I> extends AbstractPageBean implem | @@ -75,9 +75,6 @@ public abstract class AbstractEditPageBean<T, I> extends AbstractPageBean implem | ||
| 75 | @Name("demoiselle-jsf-bundle") | 75 | @Name("demoiselle-jsf-bundle") |
| 76 | private ResourceBundle bundle; | 76 | private ResourceBundle bundle; |
| 77 | 77 | ||
| 78 | - @Inject | ||
| 79 | - private transient FacesContext facesContext; | ||
| 80 | - | ||
| 81 | protected void clear() { | 78 | protected void clear() { |
| 82 | this.id = null; | 79 | this.id = null; |
| 83 | this.bean = null; | 80 | this.bean = null; |
| @@ -124,6 +121,7 @@ public abstract class AbstractEditPageBean<T, I> extends AbstractPageBean implem | @@ -124,6 +121,7 @@ public abstract class AbstractEditPageBean<T, I> extends AbstractPageBean implem | ||
| 124 | throw new DemoiselleException(bundle.getString("id-converter-not-found", getIdClass().getCanonicalName())); | 121 | throw new DemoiselleException(bundle.getString("id-converter-not-found", getIdClass().getCanonicalName())); |
| 125 | 122 | ||
| 126 | } else { | 123 | } else { |
| 124 | + FacesContext facesContext = Beans.getReference(FacesContext.class); | ||
| 127 | return (I) converter.getAsObject(facesContext, facesContext.getViewRoot(), id.getValue()); | 125 | return (I) converter.getAsObject(facesContext, facesContext.getViewRoot(), id.getValue()); |
| 128 | } | 126 | } |
| 129 | } | 127 | } |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/template/AbstractPageBean.java
| @@ -37,10 +37,10 @@ | @@ -37,10 +37,10 @@ | ||
| 37 | package br.gov.frameworkdemoiselle.template; | 37 | package br.gov.frameworkdemoiselle.template; |
| 38 | 38 | ||
| 39 | import javax.faces.context.FacesContext; | 39 | import javax.faces.context.FacesContext; |
| 40 | -import javax.inject.Inject; | ||
| 41 | 40 | ||
| 42 | import br.gov.frameworkdemoiselle.annotation.NextView; | 41 | import br.gov.frameworkdemoiselle.annotation.NextView; |
| 43 | import br.gov.frameworkdemoiselle.annotation.PreviousView; | 42 | import br.gov.frameworkdemoiselle.annotation.PreviousView; |
| 43 | +import br.gov.frameworkdemoiselle.util.Beans; | ||
| 44 | 44 | ||
| 45 | /** | 45 | /** |
| 46 | * Template Managed AuthenticationBean class that implements the methods defined by the interface PageBean. | 46 | * Template Managed AuthenticationBean class that implements the methods defined by the interface PageBean. |
| @@ -52,15 +52,13 @@ public abstract class AbstractPageBean implements PageBean { | @@ -52,15 +52,13 @@ public abstract class AbstractPageBean implements PageBean { | ||
| 52 | 52 | ||
| 53 | private static final long serialVersionUID = 1L; | 53 | private static final long serialVersionUID = 1L; |
| 54 | 54 | ||
| 55 | - @Inject | ||
| 56 | - private transient FacesContext facesContext; | ||
| 57 | - | ||
| 58 | private String nextView; | 55 | private String nextView; |
| 59 | 56 | ||
| 60 | private String previousView; | 57 | private String previousView; |
| 61 | 58 | ||
| 62 | @Override | 59 | @Override |
| 63 | public String getCurrentView() { | 60 | public String getCurrentView() { |
| 61 | + FacesContext facesContext = Beans.getReference(FacesContext.class); | ||
| 64 | return facesContext.getViewRoot().getViewId(); | 62 | return facesContext.getViewRoot().getViewId(); |
| 65 | } | 63 | } |
| 66 | 64 |
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/util/Locales.java
| @@ -42,7 +42,6 @@ import java.util.Locale; | @@ -42,7 +42,6 @@ import java.util.Locale; | ||
| 42 | 42 | ||
| 43 | import javax.enterprise.context.SessionScoped; | 43 | import javax.enterprise.context.SessionScoped; |
| 44 | import javax.faces.context.FacesContext; | 44 | import javax.faces.context.FacesContext; |
| 45 | -import javax.inject.Inject; | ||
| 46 | import javax.inject.Named; | 45 | import javax.inject.Named; |
| 47 | 46 | ||
| 48 | /** | 47 | /** |
| @@ -64,9 +63,6 @@ public class Locales implements Serializable { | @@ -64,9 +63,6 @@ public class Locales implements Serializable { | ||
| 64 | System.out.println(); | 63 | System.out.println(); |
| 65 | } | 64 | } |
| 66 | 65 | ||
| 67 | - @Inject | ||
| 68 | - private transient FacesContext facesContext; | ||
| 69 | - | ||
| 70 | /** | 66 | /** |
| 71 | * Set the language to "en_US". This is a shorthand to <code>setLocale(Locale.US)</code>. | 67 | * Set the language to "en_US". This is a shorthand to <code>setLocale(Locale.US)</code>. |
| 72 | */ | 68 | */ |
| @@ -142,10 +138,6 @@ public class Locales implements Serializable { | @@ -142,10 +138,6 @@ public class Locales implements Serializable { | ||
| 142 | } | 138 | } |
| 143 | 139 | ||
| 144 | private FacesContext getContext(){ | 140 | private FacesContext getContext(){ |
| 145 | - if (facesContext==null){ | ||
| 146 | - facesContext = Beans.getReference(FacesContext.class); | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - return facesContext; | 141 | + return Beans.getReference(FacesContext.class); |
| 150 | } | 142 | } |
| 151 | } | 143 | } |