New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] metadata redirect component #119

Closed
djmj opened this Issue Mar 28, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@djmj

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.

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

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

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Apr 7, 2015

Member

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

Member

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

This comment has been minimized.

Show comment
Hide comment
@djmj

djmj 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:
http://stackoverflow.com/questions/25241437/invoke-fviewaction-conditionally-based-on-fviewparam

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:
http://stackoverflow.com/questions/25241437/invoke-fviewaction-conditionally-based-on-fviewparam

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

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Sep 28, 2015

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC Sep 28, 2015

Member

It's available in today's latest snapshot.

Member

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