According to the Primefaces 6.2 user guide the attributes stand for
Name | Default | Type | Description
[...]
url | null | String | Url to be navigated when menuitem is clicked
[...]
outcome | null | String | Navigation case outcome
where "outcome" is a synonym of the description for url. I would like to avoid using them wrongly.
The answer is :
outcome refers to a JSF page in your application or a navigation rule defined in your faces-config.xml
url simply opens the given address, which could be on another website.
Using outcome is a great feature, because if the targeted JSF page does not exist, the link is not produced, so you will not have a 404 response when clicking on it.
Related
I am a little confused by Liferay's friendly URL mechanism and utility classes.
Can someone please explain this URL to me in detail?
http://127.0.0.1:8080/web/guest/home
^ ^ ^ ^ ^ ^
Prot. Hostname | | | Layout FriendlyURL
Port | Sitename
???
Part 4 web is a miracle to me and seems to be indicating if the site is staged, public or private?
The next question would be, which UtilClass to use to guarantee that a certain layout exists in that site.
You're right, the web part indicates the the site is public and for private pages ot would be group.
To check if a layout exists get the friendlyUrl of the layout use :
LayoutLocalServiceUtil.getFriendlyURLLayout(long groupId, boolean privateLayout, String friendlyURL)
If this doesn't suit you there are other methods in this class that may.
Liferay Doc: LayoutLocalServiceUtil
I am working on a project using Liferay 6.2 on JBoss ES 6.2. I need to be able to create a action URL inside an action method. The action method is looking up some data, building a JSONArray, and then setting an attribute equal to the resulting JSON string. Part of that JSON data needs an action url to another action within the same portlet.
The problem I am running into is that the generated URL seems to force any parameters I set include two underscores to the parameter name.
For instance:
PortletURL actionUrl = PortletURLFactoryUtil.create(actionRequest, portletId, plid, PortletRequest.ACTION_PHASE);
actionUrl.setPortletMode(LiferayPortletMode.VIEW);
actionUrl.setWindowState(WindowState.NORMAL);
actionUrl.setParameter("guid", guid);
actionUrl.setParameter("javax.portlet.action", "myAction");
Ends up generating something like:
http://localhost:8000/group/mySite/myPortlet?p_auth=fsdweD2&p_p_id=p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&__guid=1234567890&__javax.portlet.action=myAction
Notice the __guid and __javax.portlet.action. As a result, the portlet ends up running the doView() instead of myAction().
I have also tried to create a friendly url to solve the issue, but then I run into the issue of how to generate the friendly url with the proper site context AND the required p_auth value.
URL generated doesn't have portlet ID set properly as I see p_p_id is empty in URL. Please check if you are passing correct portlet ID.
Our project uses a Web Application developed using JSF, primefaces, xhtml. Currently user can login and navigate through pages sequentially by clicking on 'action' links, like:-
index.xhtml --> login.xhtml --> classes.xhtml --> students.xhtml --> student_info.xhtml
i.e. first login --> shows the list of classes --> user selects a class --> shows the list of students in that class --> user selects a student --> shows the student info.
Each of the pages has its own 'backing bean' classes. They are instantiated as and when the user clicks through the pages.
Also, user can navigate back via certain links on each page-- say, from 'student_info' page, he/she can go back to the 'students' page.
Now requirement is: user can directly go to an inner page, say, student_info page by typing an 'url' with additional parameters, ?user=alice,?passwd=xyz, ?class=5, ?studentRollNo=15.
Also, the user should still be able to navigate back to other pages (i.e. once the page is opened, their should be no behavior difference whether the user navigated normally to student_info page or, whether he directly provided url with parameters).
My questions are:-
How to read url parameters in JSF?
Which page (or backing bean) should handle the parameters? Should it be done centrally, or, in each page (backing bean) ?
In case each page handles its relevant parameters only -- is there way to redirect remaining parameters to the next page ?
What are the best practices used in such implementations?
Note:
Actual web application is much more complex, tried to provide a simpler picture which pinpoints my problem.
new to JSF, Web App etc. Don't know if there are some JSF terminologies to describe above issues.
you can pass it by url request, and each BackingBean handle it
ex:
mypage.xhtml?myparam=test
and inject the HttpServletRequest in your BackingBean (if you are using CDI)
#Inject
HttpServletRequest request;
and get the param
#PostConstruct
public void init() {
String myparam = request.getParameter("myParam");
}
for redirect to other page you can use
public String redirect() {
return "otherPage.xhtml?faces-redirect=true&otherParam=test";
}
I have two liferay portlets designed like this
--------------------- ---------
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
--------------------- ---------
I want to add a link using JSF primefaces in the portlet on the right side, if i click on it, this portlet is minimized, and it's space is taken by the portlet on the left side.
Any leads ?
You might want to start from Inter portlet Communication
I would suggest you use one portlet for this, and minimize using some of JavaScript tools
Also, check primefaces tree nodes and use ajax update to update the second panel.
As far as I know, there is no expanding and shrinking in portlets' world. if those portlets are tightly connected, you might want to consider merging them into one.
Thanks devBinnooh for your answer,
Actually you'r right, it's preferable to use only one portlet because using 2 of them will create a lot of problems (such us communication which i beleive it's not an easy task).
Concerning primefaces i've used the component p:layoutUnit with the property collapsible="true". and it works fine for me.
I've got to implement navigation using a main menu (easy) but then each menu will lead to a group of pages that have another "submenu" which I've implemented as a menu widget in the before content area.
The main navigation is something like this:
Home | First Group | Some page | Another page | Second Group | Yet another page
When the user clicks Home, Some page, Yet another page, it is taken directly to that page.
If the user clicks any of the "groups" it is taken to the "default page" for that group, and a submenu which is implemented as a menu widget is shown in the before content area. The first group can have 5 pages
Page 1.1 | Page 1.2 | Page 1.3 | Page 1.4 | etc.
The Second Group will have another set of pages.
I've naively set the path properties for the subpages so that they share a common path:
/group-1/page-1-1
/group-1/page-1-2
/group-2/page-1-3
etc.
/group-2/page-2-1
/group-2/page-3-1
etc.
I was expecting to use the Match Path to hide one widget menu in under one path or the other. But the problem is that I can't target a specific Menu or Widget, only content types in general, etc. I can't do something like this:
<Match Path="/group-1/*" ContentType="Widget SOME WAY TO TARGET A SPECIFIC WIDGET!!!">
<!-- SEND THE NEEDED PARTS TO OBLIVION SO THAT ONLY THE CORRECT MENU SHOWS HERE --!>
<Place Parts_Common_Body="-" />
</Match>
I believe that it would be much better to use a layer rule to target a specific path, but I just can't match a layer rule to something like url("/group-1/*"), so that's why I've tried to use the placement info which seems to be the wrong tool.
Is there a way I can extend the layer rules to work with regular expressions, for example? This way I can create really powerful layers and just layout my widgets on the proper layers.
In summary what I want is to have different submenus for different sections of the site. I'm just kind of lost on how to accomplish that, but layer rule seem to be the right tool, only if I could manage to use a little more powerful matching syntax.
I think I'm kind of blind!!!
Straight from the docs:
url("<url path>")
True if the current URL matches the specified path. If you add an asterisk (*) to the end of the path, all pages found in subfolders
under that path will evaluate to true (for example, url("~/home*")).
So adding this rule was enough to create a layer for an entire section of the site:
url("~/group-1*")
I'm almost ashamed of myself...