0

I am trying to learn navigation (Page Forward vs Page Redirect) in jsf 2.2. I came across this problem of URL update in jsf. I have written some tests and the URL is always update in my case.

page 1:

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                template="components/defaultLayout.xhtml">

    <ui:param name="bodyClass" value="container body-nomargin" />

    <ui:define name="body">


        <h1>Welcome </h1>


        <h:panelGroup layout="block" styleClass="col-md-12">

            <h:form>
                <h:link outcome="detail" value="some value"> </h:link>
            </h:form>


        </h:panelGroup>

    </ui:define>

</ui:composition>

detail page:

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                template="components/defaultLayout.xhtml">

    <ui:param name="bodyClass" value="container body-nomargin" />

    <ui:define name="body">

        <h:outputLabel value="Hello, world"/>

    </ui:define>

</ui:composition>

1) Does this issue of URl not being updated even exists in jsf 2.2 anymore or am i referring to an outdated source here (source mentions it is for jsf 2.0 but i am guessing things would be the same for jsf 2.2. )?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
gogogaga
  • 175
  • 1
  • 3
  • 11
  • Off-topic: don't mix jsf 2.2 and pre jsf-2.2 namespaces. Might result in undefined behaviour – Kukeltje Jan 02 '18 at 15:22
  • @Kukeltje So are you saying that this was the behavior in jsf 2.0 but does not exist in jsf 2.2? Also, can you kindly share a link for jsf 2.2 namespaces? – gogogaga Jan 03 '18 at 09:01
  • @Kukeltje How am i mixing the namespaces? Sorry i am new to jsf – gogogaga Jan 03 '18 at 09:12
  • This: _xmlns:ui="http://java.sun.com/jsf/facelets"_ is pre jsf-2.2, and this: _ xmlns:h="http://xmlns.jcp.org/jsf/html"_ is jsf 2.2. For a link about the namespaces... Lots of info on google (and adding 'stackoverflow' in the search helps) – Kukeltje Jan 03 '18 at 10:10

1 Answers1

2

You don't see this behaviour since you use an h:link which according to the specs (emphasis mine)

Execute the Algorithm to obtain the URL to which the user-agent should issue a GET request when clicked.

So you effectively 'fixed' the problem by not creating it in the first place.

See also bullet 1 in the answer

Kukeltje
  • 12,223
  • 4
  • 24
  • 47