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 | 75 | @Name("demoiselle-jsf-bundle") |
| 76 | 76 | private ResourceBundle bundle; |
| 77 | 77 | |
| 78 | - @Inject | |
| 79 | - private transient FacesContext facesContext; | |
| 80 | - | |
| 81 | 78 | protected void clear() { |
| 82 | 79 | this.id = null; |
| 83 | 80 | this.bean = null; |
| ... | ... | @@ -124,6 +121,7 @@ public abstract class AbstractEditPageBean<T, I> extends AbstractPageBean implem |
| 124 | 121 | throw new DemoiselleException(bundle.getString("id-converter-not-found", getIdClass().getCanonicalName())); |
| 125 | 122 | |
| 126 | 123 | } else { |
| 124 | + FacesContext facesContext = Beans.getReference(FacesContext.class); | |
| 127 | 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 | 37 | package br.gov.frameworkdemoiselle.template; |
| 38 | 38 | |
| 39 | 39 | import javax.faces.context.FacesContext; |
| 40 | -import javax.inject.Inject; | |
| 41 | 40 | |
| 42 | 41 | import br.gov.frameworkdemoiselle.annotation.NextView; |
| 43 | 42 | import br.gov.frameworkdemoiselle.annotation.PreviousView; |
| 43 | +import br.gov.frameworkdemoiselle.util.Beans; | |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 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 | 52 | |
| 53 | 53 | private static final long serialVersionUID = 1L; |
| 54 | 54 | |
| 55 | - @Inject | |
| 56 | - private transient FacesContext facesContext; | |
| 57 | - | |
| 58 | 55 | private String nextView; |
| 59 | 56 | |
| 60 | 57 | private String previousView; |
| 61 | 58 | |
| 62 | 59 | @Override |
| 63 | 60 | public String getCurrentView() { |
| 61 | + FacesContext facesContext = Beans.getReference(FacesContext.class); | |
| 64 | 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 | 42 | |
| 43 | 43 | import javax.enterprise.context.SessionScoped; |
| 44 | 44 | import javax.faces.context.FacesContext; |
| 45 | -import javax.inject.Inject; | |
| 46 | 45 | import javax.inject.Named; |
| 47 | 46 | |
| 48 | 47 | /** |
| ... | ... | @@ -64,9 +63,6 @@ public class Locales implements Serializable { |
| 64 | 63 | System.out.println(); |
| 65 | 64 | } |
| 66 | 65 | |
| 67 | - @Inject | |
| 68 | - private transient FacesContext facesContext; | |
| 69 | - | |
| 70 | 66 | /** |
| 71 | 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 | 138 | } |
| 143 | 139 | |
| 144 | 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 | } | ... | ... |