how to generate link to "Manage Page" in Liferay? - java

I'm developing simple pages navigation portlet, and for each page I would like to have link to its "Manage Page" ("Manage > Page" in the top navigation bar)
Do you have any ideas how this link can be generated?
Thanks,
Karol

Sorry I needed to add another answer as the comment had less charachters. For each url you have to create pageSettingsURL as under. Write the following logic in a loop for all the layouts of the community you are interested in using LayoutLocalServiceUtil class and pass the plid
PortletURL pageSettingsURL = new PortletURLImpl(
request, PortletKeys.LAYOUT_MANAGEMENT, plid,
PortletRequest.RENDER_PHASE);
pageSettingsURL.setWindowState(WindowState.MAXIMIZED);
pageSettingsURL.setPortletMode(PortletMode.VIEW);
pageSettingsURL.setParameter(
"struts_action", "/layout_management/edit_pages");
if (layout.isPrivateLayout()) {
pageSettingsURL.setParameter("tabs1", "private-pages");
}
else {
pageSettingsURL.setParameter("tabs1", "public-pages");
}
pageSettingsURL.setParameter("redirect", currentURL);
pageSettingsURL.setParameter(
"groupId", String.valueOf(scopeGroupId));
pageSettingsURL.setParameter("selPlid", String.valueOf(plid));

Try
themeDisplay.getURLPageSettings().toString()
You should get themeDisplay in jsp page if you are using
You should get themeDisplay as request attribute in your portlet class

Related

How to make id clickable and link to another jsp page

Database result screenshot has been attached. Now i want to make emp_no clickable and link it to another jsp file for more details.
Need suggestions.
Simplest option is to use the anchor tag and link it to the appropriate controller:
Something like this:
<a href='employeeInfoController?id=<%=id>'><%=id></a>
employeeInfoController is your Controller Servlet or JSP that shows the details of the employee whose id is passed as a parameter. The controller can be a JSP or a serlvet.
You will need to put in all the appropriate checks to ensure the person viewing the details is authorized, etc.
Hope this helps!

Change page name in Tapestry

I'm beginner with Tapestry. I have a component called Navigation, where I dynamically get the pageName of my web pages, and display the link in header of a website. Here's the relevant part:
<t:loop source="pages" value="row">
<li><t:pagelink t:page="${page}">${pageName}</t:pagelink></li>
</t:loop>
That works ok.
I have page About_us.tml, and About_us.java. That page contains only text, so it's simple. My problem is, that my Navigation component displays this page in header (where are links to all of the pages of my web app) as About_us link. I want to change this to About us link. I don't want the "_" sign.
Any idea how could I possibly solve this?
Thanks.
It's very easy to pass the pageName through a bit of Java code to prepare it to be presented.
public String prepare(String pageName) { return pageName.replace("_", " "); }
and
<t:pagelink ...>${prepare(pageName)}</t:pagelink>

displaying portlet in another portlet without popup

Is there any way in to display one portlet in an other portlet ?
Problem i am facing is that i have two portlets in Liferay,i want's to display the complete second portlet in the reserved div area of the first portlet,so that i can use all the functionality of second portlet in the first one(I don't want to use popup for this particular scenario). or in other words
i wants nested portlet
I have Google this but didn't find any helping material ,now my question is this scenario is possible in Liferay?
Any helping will be greatly appreciated.
Hi Use nested portlet.
Emded portlet example
or
use web content display portlet inside you can display portlet
or you can use Liferay Portlet Sharing java script code..
i have small following snippet it will render portlet in div but it wont peforn actions because its static content
the following is example snippet to load portlet in div
AUI().use('aui-base','aui-node','aui-dialog','aui-io-request', 'aui-io','liferay-portlet-url','aui-dialog-iframe', function(A) {
var url =Liferay.PortletURL.createRenderURL();
url.setPortletId('signinaction_WAR_WatsonSiginInportlet');
url.setWindowState('pop_up');
var myAjaxRequest=A.io.request(url.toString(), {
dataType: 'html',
autoLoad: false,
on: {
success: function() {
// A.one('#testestDiv').set('innerHTML',"meera");
document.getElementById("login-portlet-content").innerHTML=this.get('responseData');
//A.one('#loginBoxDiv').set('innerHTML',this.get('responseData'));
}
}
});
myAjaxRequest.start();
});

How to show the content of a log file in new window when we click on a link in spring mvc

My main goal: When i click the link, a new browser window should be opened and displays the content of entire log file. And the window should not have an address bar and navigation buttons (Back, Forward).
Is there any approach to do this in Spring-MVC project?
Here is what i am doing now:
When i click the link, the controller will be called with a parameter logName.
Now the controller have access to get any kind of details of the log file like content, path, etc... I am setting all these details to an object and sending back to JSP.
Here i am not sure how to open a new window and display the content of the log file in that window.
Please suggest me an approach on this!!
It would be very helpful for me if you can share me with some examples...
Spring or JSP have nothing to do with it, the only way to force user's browser to open a link in a new tab is to use client-side Javascript. window.open() allows configuring the popup to hide certain interface elements (see all options in the documentation)
Your code would look something like:
<input type="button" value="Show Log" onclick="showLog(logName)">
function showLog(logName) {
var url = "/path-to-your-controller.html?logName=" + logName;
window.open(url, "LogPage", "toolbar=no,location=no,menubar=no");
}
However, I don't think using a customised browser popup is a good solution; it's been disappearing from the web for a reason. It would be more elegant to fetch raw data using AJAX and display it in a JS popup: it wouldn't interfere with user's page navigation (you tagged the question with jQuery, you could use jQuery UI for that).
What is more, I wouldn't be surprised if window.open wasn't supported by all browsers in the same way† - something to keep in mind if you're targeting a wider audience.
† seems that Chrome ignores location=no, for instance

Is there is any way to scrape the dynamic content using php or java

I need to scrape some details from a website. It loads certain details in Ajax after a button click. Is it is possible to scrape the details from this link?
It loads the details when the + button is pressed.
Yes, you can. Use an ajax callback function and clean the response you receive according to your wishes:
var ajaxurl ='myserver.com/mypage.php';
var ajaxparams = {
do: 'get_my_page',
}
$.post(ajaxurl, ajaxparams, function(response, status){
if (status == 'success')
{
//handle the response her and clean it
}
}
The URL from which the site loads the dynamic content with Ajax is apparently randomly generated, so you will have to scrape it from the HTML of the original page. It can be found in calls to the Javascript function getMusicDetails which is called in the link onclick handlers as follows:
<a onclick="getMusicDetails('0','/md?doc=random_doc_id_here&q=3%20idiots','both');..." />
There doesn't seem to be any session-specific protection of the content, so once you have the ID, it should simply be a matter of issuing a GET to the following URL: http://www.guruji.com/md?doc=random_doc_id_here&q=3%20idiots&rindex=0
(The sample data covers the first plus-link on the page, the other parameters might also vary)

Categories

Resources