3

I learned building a web-app with Java and Seam (and JSF 1.2)

But now i'm working at the moment with pure Java EE 6 and JSF (Mojara 2.0.9) - without any extra Framework around.

In Seam i used for the index.xhtml the index.page.xmlfor restriction:

<restrict>#{authorizationManager.isAdmin()}</restrict>

Is there any equal function like the page.xml?

And:
I also used the index.page.xml to make some calls like:

<action execute="#{indexController.doSomething()}" on-postback="false"/>

Is it now the only chance to do it with an @PostConstruct in the Controller for the .xhtml?

Also how i'm doing something like this without the page.xml?

<navigation>
    <rule if-outcome="OK">
        <redirect view-id="/pages/index.xhtml" />
    </rule>
</navigation>

It seems to me, the pure JavaEE works totaly different?

(you don't have to send me full code, just give me the key words i have to google, thanks!)

Joergi
  • 1,527
  • 3
  • 39
  • 82
  • Why did you expect that Java EE 6 has taken over all features of Seam? Why don't you just install Seam if you like its features? – BalusC Mar 01 '12 at 12:55
  • i want to make an application which uses the standards, without seam.. i'm sure Java EE 6 has (hopefully) some equivalent features, or some best practise to do it? – Joergi Mar 01 '12 at 15:50

1 Answers1

5

In Seam i used for the index.xhtml the index.page.xmlfor restriction:

<restrict>#{authorizationManager.isAdmin()}</restrict>

Is there any equal function like the page.xml?

Standard JSF does not offer any builtin authenticaiton/authorization facilities. All is to be used from the "raw" Servlet API or a 3rd party framework like Spring Security.

As to the "raw" Servlet API facilities, the <security-constraint> in web.xml comes close. You can only restrict on global URL patterns like /app/*, not on a per-page or maybe per-action basis.


I also used the index.page.xml to make some calls like:

 <action execute="#{indexController.doSomething()}" on-postback="false"/>

Is it now the only chance to do it with an @PostConstruct in the Controller for the .xhtml?

The <f:event> in the XHTML page itself comes close:

<f:event type="preRenderView" listener="#{indexController.doSomething}" />

As to the on-postback replacement, check Is it possible to disable f:event type="preRenderView" listener on postback?.


Also how i'm doing something like this without the page.xml?

<navigation>
    <rule if-outcome="OK">
        <redirect view-id="/pages/index.xhtml" />
    </rule>
</navigation>

It seems to me, the pure JavaEE works totaly different?

JSF 2.0 supports implicit navigation which makes <navigation-rule> in faces-config.xml totally superfluous. The returned outcome will be implicitly treated as target view ID. You can perform a redirect by appending a faces-redirect=true parameter to the outcome query string. E.g.

public String submit() {
    // ...

    return "/pages/index.xhtml?faces-redirect=true";
}

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555