Re: h:link rendered as http://bla?com.ocpsoft.mappingId=home

Splash Forums PrettyFaces Users h:link rendered as http://bla?com.ocpsoft.mappingId=home Re: h:link rendered as http://bla?com.ocpsoft.mappingId=home

#21634

Hey multanis,

there are many different ways for navigating when using PrettyFaces. Let me first comment on the three ways you mentioned in you post:

1. <h:link>


You are not using the h:link correctly here. You have to add the values of the path parameters with <f:param> tags to the component. Please have a look at the documentation for details:

http://ocpsoft.com/docs/prettyfaces/3.3.0/en-US/html/outbound_rewriting.html#jsf

2. <h:commandLink>


You are correct. This way should not be used as it creates a postback and not a standard HTML link.

3. <pretty:link>


This is the way I prefer in my applications. But you will have to add the desired values of the path parameters here too (like for <h:link>).

I think that your mapping is a bit different from other mappings because the path parameters typically keep their “current value” for all links generated on the page, correct? But this is some kind of a special case. Typically users want to specify the values of the path parameters as they are different for each link. Therefore the components don’t read the current values from the path parameters but instead offer a way to set them using <f:param> tags. Take a look at this typical example for a mapping:

<url-mapping id="viewCategory">
<pattern value="/store/#{ categoryBean.categoryName }/" />
<view-id value="/faces/shop/store.jsf" />
</url-mapping>

<h:dataTable var="cat" value="#{someBean.categories}">
<h:column>
<pretty:link mappingId="viewCategory">
<f:param value="#{ cat.name }" />
</pretty:link>
</h:column>
</h:dataTable>

As you see from this typical example it makes absolutely sense to specify the values for the path parameters using <f:param> tags.

So I guess you will have to add the <f:param> tags and go with 1. or 3. to implement what you want. But you could build a simple composite component to simplify the process of creating the links. This should take only a view minutes.

I hope this helps! :)

Christian