displaying portlet in another portlet without popup - java

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();
});

Related

Ajax form updates in JSF shows ViewExpiredException

I have a jsf 1.2 application with some links in the index page. This links are oppened by clicks, on new jquery dialogs. Every link open a new page of my app in a distinct dialog, so, the application can open many links in many dialogs in a single page. All my managed beans have session scope.
My problem is, when i open a new dialog and click in any link inside, my application still works fine, but after this, if i click in other link in my index page to open another dialog, the app shows me a ViewExpiredException. I have tried update my jsf to 2.0, set EnableRestoreView11Compatibility in web.xml to true, use keepAlive in my beans, but nothing works.
I think its happened because i have a main page with one state and, when i click to open a new page in a jquery dialog, it loads the entire page and put the html inside. So, the request made no reference to the state of main page. How can i resolve this?
It seems like the bug in JSF which is not fixed yet , it is planned for fix in JSF 2.3
You can use the below workaround posted in java.net for the jquery.
http://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-790
var patchJSF = function () {
jsf.ajax.addOnEvent(function (e) {
if (e.status === 'success') {
$("partial-response:first changes:first update[id='javax.faces.ViewState']",
e.responseXML).each(function (i, u) {
// update all forms
$(document.forms).each(function (i, f) {
var field = $("input[name='javax.faces.ViewState']", f);
if (field.length == 0) {
field = $("<input type=\"hidden\" name=\"javax.faces.ViewState\" />").
appendTo(f);
}
field.val(u.firstChild.data);
});
});
}
});
}

How can I reload only a part of code - Java

I have a JSP page that at the end comes a pop-up window from a javascript, I want after the users click to reload only a specific part of the JSP page more specific one if - loop want to be reloaded one more time ...can this happened or the idea is totally wrong ?
What you are looking for is called AJAX.
AJAX is the art of exchanging data with a server, and updating parts
of a web page - without reloading the whole page.
jQuery has a very nice ajax api.
To load html pages, you could use jQuery.load like this:
$("#result").load( "ajax/test.html" );
You can also generate dynamic html by calling a REST function of a php page using a different url. Example:
var data = { limit: 25, otherProp: "val" }
$("#result").load( "getHtmldata.php", data);

How to select the particular row data in jsp using radio button

I know its a basic question and please bear with this.
I'm new to struts frame work and I'm creating a sample application using struts 1.2. I've inserted few values into the database using form beans. And i'm displaying all the database records in the jsp page using function. and i also placed the radio button for each row..
Now my question is, i want to select a particular data from the records displayed in the jsp page by clicking the radio button and i need to store the selected records into the another table.
Give me some suggestion regarding the condition specified above...
Thanks in advance..
Once you set those unique values in radio button, you can get the values for your purpose. Like using jquery,
var selRadio = $('input:radio[name=cname]:checked').val();
You can find out fiddle explains how to get checked value.
Use some ajax for send that value to server (servlet) and add the values to new table without refresh entire page.
$.ajax({
url : "ur_servlet_url" + selRadio,
type : "POST",
async : false,
success : function(data) {
alert("success");
}
});
Let me know if this helps.

Need to display hosted html page in full screen on page load

I am developing a GWT web application and for a specific requirement I need to display my only hosted html page in full screen on load.
This we done with the help of pressing F11 on any web page. I need exactly the same functionality in my GWT application.
I have tried glimpses of Javascript for this which wasn't worked.
<script language="JavaScript1.2">
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById)
{
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
</script>
Could it be possible?
You can't force the user on how to display your document. Still, there's a Draft for a fullscreen api, see also https://developer.mozilla.org/en/DOM/Using_full-screen_mode
I think you will need to use the page you load to launch a new browser window with the fullpage html in it. The first page is nothing but to kick off the full page with a script like this
<script>
<!--
window.open("fullpage.html","fs","fullscreen=yes")
//-->
</script>

show and hide a portlet when clicking on a link inside another portlet

I have three portlets for example: portletA, portletB and portletC.
portletA displays on left side and it has two links linkB and linkC.
If I click on linkB then portletB should be displayed on right side and If I click on linkC then portletB must become hidden and portletC should be displayed.
Please, tell me how I can do this using ICEfaces.
I used this code to hide the portlet but after refreshing the page again portlet is visible can you suggest what I can do so that after refreshing portlet should not visible?
function fun(E)
{
if(E=="Entry")
{
alert("hi");
document.getElementById("p_p_id_ipc_WAR_IPC2portlet_").style.display='none';
document.getElementById("p_p_id_ipc1_WAR_IPC2portlet_").style.display = '';
}
else
{
alert("else");
}
}
</script>
You can do it with simple javascript and css. What you have to do is see what portlet B and C portlet id's are and than using javascript you can alter css "display" property on the portlet boundary div.
Using simple javascript
var p = document.getElementById("p_p_id_YOUR-PORTLET-ID_");
if (p) {
if (p.style.display == "none") {
p.style.display = "block";
} else {
p.style.display = "none";
}
}
Using jQuery
jQuery("p_p_id_YOUR-PORTLET-ID_").show();
//or
jQuery("p_p_id_YOUR-PORTLET-ID_").hide();
Examples are for showing/hiding single portlet. In your case link B should hide C and show B, and link C other way around.
Also take a look at Client-side Inter-Portlet Communication

Categories

Resources