[seam-issues] [JBoss JIRA] Commented: (SEAMFACES-95) Make ProjectStage available from EL

Dan Allen (JIRA) jira-events at lists.jboss.org
Mon Mar 14 01:55:45 EDT 2011


    [ https://issues.jboss.org/browse/SEAMFACES-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12587645#comment-12587645 ] 

Dan Allen commented on SEAMFACES-95:
------------------------------------

Doh, I'm didn't realize it was available on Application. When I saw the isProjectStage() on FacesContext, I just assumed there was no getter. Who the heck designed this API?

I hate how hard it is to reach projectStage, so I think we should keep our producer. But it should return the enum. Technically it could be made @ApplicationScoped since it shouldn't be changing mid-run.

@Named @ApplicationScoped
public ProjectStage getProjectStage(FacesContext ctx) {
   return ctx.getApplication().getProjectStage();
}

The motivation for the simpler EL name is because it will be used often. This could be later addressed by an "EL namespace import feature" that we've discussed in the past.  

> Make ProjectStage available from EL
> -----------------------------------
>
>                 Key: SEAMFACES-95
>                 URL: https://issues.jboss.org/browse/SEAMFACES-95
>             Project: Seam Faces
>          Issue Type: Feature Request
>          Components: CDI Integration
>    Affects Versions: 3.0.0.CR1
>            Reporter: Dan Allen
>            Assignee: Brian Leathem
>            Priority: Minor
>             Fix For: 3.0.0.Final
>
>
> There is no easy way to reach the project stage from EL, nor can you easily check which ProjectStage is active. The only way to access the ProjectStage is by referencing the context parameter directly:
> #{initParam['javax.faces.PROJECT_STAGE']}
> Seam Faces should make it available as
> #{projectStage}
> This also makes it possible to check which project stage is active.
> #{projectStage eq 'Development'}
> Without an implicit projectStage variable, that's not possible via EL, even with method parameters, because the signature of the comparison method is as follows:
> FacesContext#isProjectStage(ProjectStage)
> Since enums can't be referenced directly from EL (without an explicit producer), there is no way to use this method. Thus, it might make sense to expose a project stage map that allows the enum values to be referenced:
> #{projectStages.Development}
> Then it would be possible to execute:
> #{facesContext.isProjectStage(projectStages.Production)}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the seam-issues mailing list