Reputation: 611
I have the following site structure:
web
|_events
|_view.xhtml
|_news
|_view.xhtml
|_pages
|_view.xhtml
...
When a user clicks a link to, let's say, Event #4, he will be redirected to e.g. http://example.com/events/view.xhtml?itemId=4
On the event->view.xhtml page I have a menu with links to some other events (somehow related to the event that is currently viewed). Let's say those are Event #1 and Event #2.
Currently my menu links have value="../event/view.xhtml?itemId=#{row.id}". When it's clicked, the user will be redirected to e.g. http://example.com/events/view.xhtml?itemId=2
But if I use this approach (with "../event/" in the URL), it means that I have to create two more link types, with URLs for news and for pages. And also for every other item type that I make...
Is there any way to put only "itemId=X", i.e. only the new parameter value in the link value? Then I could use one menu template for every item type on my site.
Thanks!
Upvotes: 0
Views: 383
Reputation: 3887
You could use a List in ApplicationScope or SessionScope according to your use case and add all the type there.
Something like
public class Type implements Serializable {
private String name;
private List<Integer> items;
//getters and setters
}
Managed Bean
public class TestBean {
private List<Type> types;
@PostConstruct
public void init(){
//constructTypesAccordingToSomeLogic();
}
//getters and setter
}
View
<ui:repeat value="#{testBean.types}" var="type">
<ui:repeat value="#{type.items}" var="item">
<h:outputLink value="../#{type.name}.xhtml?itemId=#{item}"></h:outpuLink>
</ui:repeat>
</ui:repeat>
Upvotes: 1