[Feature] metadata redirect component #119

djmj opened this Issue Mar 28, 2015 · 4 comments


None yet

2 participants

djmj commented Mar 28, 2015

A metadata child component that will redirect to a target outcome depending on an el expression.

This is similar to <o:viewParamValidationFailed> but in the below use case there is no validation error, since the needed data pageInfo is from a property of the view parameter data.

In my use case i have default data to show and perform null checks where i access pageInfo, so right no I dont need it. Just thought its a nice feature.

    <o:viewParam name="foo" value="#{fooViewBean.foo}" converter="fooConverter />
    <o:redirect outcome="/sites/foo" enabled="#{fooViewBean.foo.pageInfo eq null}"/>
    <p:panel header="#{fooViewBean.foo.pageInfo.title}>

All workarounds need more Java code or beans, which i am happy to reduce as much as possible. (Thats why i like JSF, so little java to write)

Workaround 1

Current workaround is to invoke a preRenderEvent and redirect within bean.
This maybe needs to create a new method or a new managed bean (in case fooViewBean is a general bean used by many views).

Workaround 2

Create a utility request scope bean and call preRenderEvent like #{redirectBean.redirect('/sites/foo', fooViewBean.foo.pageInfo eq null)}

Workaround 3

Create a new converter to get pageInfo from foo and use a new bean.

BalusC commented Apr 7, 2015

JSF 2.2 <f:viewAction action="/sites/foo" if="#{empty param.foo}"> comes very close, only the if isn't evaluated after conversion.

djmj commented Apr 8, 2015

f:viewAction looks good, but conversion maybe important. I may submit an issue at jsf spec to evaluate the if in different phase.

Looks like same idea:

@BalusC BalusC closed this in 38b3030 Sep 28, 2015
BalusC commented Sep 28, 2015

I added <o:viewAction>, now your case is possible as below:

<o:viewAction action="/sites/foo" if="#{fooViewBean.foo.pageInfo eq null}">

The if attribute is only evaluated during action broadcast, after conversion/validation/modelupdate.

BalusC commented Sep 28, 2015

It's available in today's latest snapshot.

@BalusC BalusC added the question label Oct 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment