Fórum

how to Pass parameters

Priya Pratheep, modificado 10 Anos atrás.

how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
Hi friends,

I need to pass parameters from one portlet to another.

Below is my jsp page
<liferay-portlet:actionurl var="linkURL" portletname="xxxxxxxxxxxxxxxxxxxxxxxxxxt" windowstate="maximized">
					<portlet:param name="_spage" value="/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2" />
					<portlet:param name="csid" value="134" />
					<portlet:param name="projectid" value="43534" />
					<portlet:param name="pro_id" value="34534" /> /&gt;
			</liferay-portlet:actionurl> 
<a href="<%= linkURL%>">Submit Report</a>


It is working fine. Instead of passing projectid value="43534" I tried value="<%= projectid %>" /> .Page itself not loading. Instead of static values i need to pass values where user selected from combo.

Thanks in advance
thumbnail
Romeo Sheshi, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 35 Data de Entrada: 09/05/12 Postagens Recentes
Hi,

You have to use the Public Render Parameters o events see the liferay wiki

http://www.liferay.com/it/community/wiki/-/wiki/Main/Portlet+to+Portlet+Communication?_36_pageResourcePrimKey=6629472
thumbnail
Vilmos Papp, modificado 10 Anos atrás.

RE: how to Pass parameters

Liferay Master Postagens: 529 Data de Entrada: 21/10/10 Postagens Recentes
Perhaps you could read about the possibilities of Inter Portlet Communications: http://www.liferay.com/community/wiki/-/wiki/Main/Inter-portlet+communication
thumbnail
vijay pandey, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 44 Data de Entrada: 01/09/10 Postagens Recentes
Hi Priya

You can take the parameter from javascript and make the action url or render url in javascript function . And onsubmit of form the parameters would pass to desire action .

Cheers
Vijay Pandey
Priya Pratheep, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
Hi vijay pandey,

Get the variable through

handler: function(){	
     	handleClick();
    }

function handleClick()
      {
       var projectid = Ext.getCmp('usercombobox').getValue();
        }


Don't know how to make the action url or render url in javascript function...Can you pls help.

Thanks in advance
thumbnail
vijay pandey, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 44 Data de Entrada: 01/09/10 Postagens Recentes
Hi Priya
Can you send your JSP then i would give you proper solutions

Cheers
Vijay
Priya Pratheep, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
Button to process

  text: 'Costing Sheet',
        id:'costing_sheet',
        handler: function(){	
     	handleClick(); }


From the below line i get project id

var projectid = Ext.getCmp('usercombobox').getValue();


Below is the code i need to execute when I click costing_sheet button. instead of 3000565 i should use Ext.getCmp('usercombobox').getValue() value

<liferay-portlet:actionurl var="linkURL" portletname="apseprojectmgmtportlet_WAR_apseprojectmgmtportlet" windowstate="maximized">
					<portlet:param name="_spage" value="/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2" />
					<portlet:param name="csid" value="134" />
					<portlet:param name="projectid" value="300065" />
				
					<public-render-parameter>
					
			</public-render-parameter></liferay-portlet:actionurl> 
			


Note:
It is wokring with
<a href="<%= linkURL%>">Submit Report</a>
with static values.

Thanks in advance
Priya
thumbnail
vijay pandey, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 44 Data de Entrada: 01/09/10 Postagens Recentes
Hi Priya

I am giving you simple solutions for your problem
before doing this you must check the value of var projectid in alert at the time of loading the form that is coming or not . then do this

Ex var projectid = Ext.getCmp('usercombobox').getValue(); alert(projectid );

1) Make a <form > </form> section
2) <a href="#" onclick ="jsFunctionName()" >Submit Report</a>
3) In Javascript function jsFunctionName() ,get the parameter from the form .
4) Then make the <liferay-portlet:actionURL > url with embeding the parameter and submit the form .



Cheers
Vijay Pandey
Priya Pratheep, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
Thanks for reply
Step 1.
<form action="<liferay-portlet:actionURL var=" linkURL" portletName="apseprojectmgmtportlet_WAR_apseprojectmgmtportlet" windowState="maximized">
					<portlet:param name="_spage" value="/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2" />
					<portlet:param name="csid" value="134" />
					<portlet:param name="projectid" value="300065" />
					<portlet:param name="pro_id" value="555300065" /> /&gt;
			 " method="post" &gt;  
</form>		


Step 2.

<a href="#" onclick="jsFunctionName()">Submit Report</a>


Step 3.
  function jsFunctionName()
      {
       var projectid = Ext.getCmp('usercombobox').getValue();
       alert(projectid);
        }


How can i do step 4) Then make the <liferay-portlet:actionURL > url with embeding the parameter and submit the form .

also in jsFunctionName() how can i call form ?

Thanks in advance
Priya
thumbnail
Amit Doshi, modificado 10 Anos atrás.

RE: how to Pass parameters

Liferay Master Postagens: 550 Data de Entrada: 29/12/10 Postagens Recentes
Hi Priya,

Please check this link.

Hope it will be useful.

Thanks & Regards,
Amit Doshi
thumbnail
vijay pandey, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 44 Data de Entrada: 01/09/10 Postagens Recentes
Priya Pratheep:
Thanks for reply
Step 1.
<form action="<liferay-portlet:actionURL var=" linkURL" portletName="apseprojectmgmtportlet_WAR_apseprojectmgmtportlet" windowState="maximized">
					<portlet:param name="_spage" value="/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2" />
					<portlet:param name="csid" value="134" />
					<portlet:param name="projectid" value="300065" />
					<portlet:param name="pro_id" value="555300065" /> /&gt;
			 " method="post" &gt;  
</form>		


Step 2.

<a href="#" onclick="jsFunctionName()">Submit Report</a>


Step 3.
  function jsFunctionName()
      {
       var projectid = Ext.getCmp('usercombobox').getValue();
       alert(projectid);
        }


How can i do step 4) Then make the <liferay-portlet:actionURL > url with embeding the parameter and submit the form .

also in jsFunctionName() how can i call form ?

Thanks in advance
Priya



@Priya
first check have you got the desired value in alert or not
Priya Pratheep, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
yes I am getting the desired value in alert.
thumbnail
vijay pandey, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 44 Data de Entrada: 01/09/10 Postagens Recentes
Now in Javascript make the action url and use document.getElementById('formID').action =<%=url%>; and document.getElementById('formID').submit();


Cheers
Vijay
Priya Pratheep, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
Hi Vijay Pandy,

My form
	<form name="myForm" action="<liferay-portlet:actionURL var=" linkURL" portletName="apseprojectmgmtportlet_WAR_apseprojectmgmtportlet" windowState="maximized">
					<portlet:param name="_spage" value="/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2" />
				 " method="post" &gt;  </form>	




The function which I called when clicking the button
function jsFunctionName()
      {
       var projectid = Ext.getCmp('usercombobox').getValue();
       alert(projectid);
        myForm.getElementById('projectid').value=projectid;
        document.getElementById('myForm').submit();
        }


To assign values
document.getElementById('projectid').value=projectid;

I am getting error of
document.getElementById(...) is null

How can i assign
<portlet:param name="projectid" value="<%=project_id%>" /> line in my function?
Thanks in advance
Priya
thumbnail
vijay pandey, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 44 Data de Entrada: 01/09/10 Postagens Recentes
Priya Pratheep:
Hi Vijay Pandy,

My form
	<form name="myForm" action="<liferay-portlet:actionURL var=" linkURL" portletName="apseprojectmgmtportlet_WAR_apseprojectmgmtportlet" windowState="maximized">
					<portlet:param name="_spage" value="/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2" />
				 " method="post" &gt;  </form>	




The function which I called when clicking the button
function jsFunctionName()
      {
       var projectid = Ext.getCmp('usercombobox').getValue();
       alert(projectid);
        myForm.getElementById('projectid').value=projectid;
        document.getElementById('myForm').submit();
        }


To assign values
document.getElementById('projectid').value=projectid;

I am getting error of
document.getElementById(...) is null

How can i assign
<portlet:param name="projectid" value="<%=project_id%>" /> line in my function?
Thanks in advance
Priya



Priya :->make the url in javascript function and there assign the param (projectid) .

Cheers
Vijay
Priya Pratheep, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
How to do
make the url in javascript function
thumbnail
Romeo Sheshi, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 35 Data de Entrada: 09/05/12 Postagens Recentes
Hi,

You can do it this way

<script>
var projectid = Ext.getCmp('usercombobox').getValue();
var portletURL = new Liferay.PortletURL('RENDER_PHASE');
portletURL.setWindowState("maximized");
portletURL.setPortletId("apseprojectmgmtportlet_WAR_apseprojectmgmtportlet")
portletURL.setParameter("_spage", "/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2");
portletURL.setParameter("csid", "134");
portletURL.setParameter("projectid", projectid);
portletURL.setParameter("pro_id", "555300065");
alert( "that is the url: " + portletURL.toString() );
</script>
thumbnail
vijay pandey, modificado 10 Anos atrás.

RE: how to Pass parameters (Resposta)

Junior Member Postagens: 44 Data de Entrada: 01/09/10 Postagens Recentes
Hi Priya

Use <script>
var projectid = Ext.getCmp('usercombobox').getValue();
var portletURL = new Liferay.PortletURL('RENDER_PHASE');
portletURL.setWindowState("maximized");
portletURL.setPortletId("apseprojectmgmtportlet_WAR_apseprojectmgmtportlet")
portletURL.setParameter("_spage", "/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2");
portletURL.setParameter("csid", "134");
portletURL.setParameter("projectid", projectid);
portletURL.setParameter("pro_id", "555300065");
alert( "that is the url: " + portletURL.toString() );
</script>

and pass this in form submission as we discussed previously

Cheers
Vijay
thumbnail
vijay pandey, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 44 Data de Entrada: 01/09/10 Postagens Recentes
use the comments of Romeo Sheshi
Priya Pratheep, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
Thank you friends

but i am getting error of Liferay.PortletURL is not a constructor .I am using liferay-portal-6.0.5

I included the tags
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>


Thanks in advance
thumbnail
vijay pandey, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 44 Data de Entrada: 01/09/10 Postagens Recentes
Priya

Use <portlet:actionURL> for making the action url

Cheers
Vijay
Priya Pratheep, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
Thanks a lot ...

Now most of the above said problem solved
I use
AUI().ready('liferay-portlet-url', function(a) {
.
Priya Pratheep, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
Hi friends,
I can create url and connect to other portlet but I am getting error of
You do not have the roles required to access this portlet.

I found that p_p_auth is creating problem

When I use the following code
<form name="myForm" action="<liferay-portlet:actionURL var=" linkURL" portletName="apseprojectmgmtportlet_WAR_apseprojectmgmtportlet" windowState="maximized">
                    <portlet:param name="_spage" value="/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2" />
                    <portlet:param name="projectid" value="300065" />
           		 "  method="post" &gt;  
  	</form>    
			<a href="<%= linkURL%>" id="ex">Direct Link</a>


My url is
http://localhost:8080/web/bmt-asia-pacific-singapore/project-consolidated-report1?p_auth=cxBoM92I&p_p_auth=FBAF8glO&p_p_id=apseprojectmgmtportlet_WAR_apseprojectmgmtportlet&p_p_lifecycle=1&p_p_state=maximized&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_apseprojectmgmtportlet_WAR_apseprojectmgmtportlet__spage=%2Fapse-projectmgmt-portlet%2Fapse-projectmgmt-portlet%2FprojectCostingSheetAction2&_apseprojectmgmtportlet_WAR_apseprojectmgmtportlet_projectid=300065

Which is working fine.

But when I use dynamic created url
function formSubmit()
{
		AUI().ready('liferay-portlet-url', function(A) {
 		var projectid = "300065"
 		var portletURL = new Liferay.PortletURL('ACTION_PHASE');
		portletURL.setWindowState("maximized");
		portletURL.setPortletId("apseprojectmgmtportlet_WAR_apseprojectmgmtportlet")
		portletURL.setParameter("_spage", "/apse-projectmgmt-portlet/apse-projectmgmt-portlet/projectCostingSheetAction2");
		portletURL.setPortletMode('view');
		portletURL.setParameter("projectid", "300065");
		portletURL.setParameter("p_p_col_id", "column-1");
		portletURL.setParameter("p_p_col_count", "1");
		
		document.getElementById('myForm').action =portletURL.toString();
   		document.getElementById('myForm').submit();
                
             });
             }


URL is
http://localhost:8080/web/bmt-asia-pacific-singapore/project-consolidated-report1?p_auth=cxBoM92I&p_p_id=apseprojectmgmtportlet_WAR_apseprojectmgmtportlet&p_p_lifecycle=1&p_p_state=maximized&p_p_mode=view&_apseprojectmgmtportlet_WAR_apseprojectmgmtportlet__spage=%2Fapse-projectmgmt-portlet%2Fapse-projectmgmt-portlet%2FprojectCostingSheetAction2&p_p_col_count=1&_apseprojectmgmtportlet_WAR_apseprojectmgmtportlet_projectid=300065&p_p_col_id=column-1
I am unable to go the the desired page and getting error of
You do not have the roles required to access this portlet.

where p_p_auth=FBAF8glO is missing.

I found from http://www.liferay.com/community/wiki/-/wiki/Main/Authentication+Token and use
<init-param>
            <name>check-auth-token</name>
            <value>false</value>
        </init-param>

in portlet.xml file. But not working...

Pls give me solution

Thanks in advance
Priya
Priya Pratheep, modificado 10 Anos atrás.

RE: how to Pass parameters

Junior Member Postagens: 38 Data de Entrada: 14/03/13 Postagens Recentes
By adding

portlet.add.default.resource.check.enabled=false
auth.token.check.enabled=false

in portlet-ext.xml file it is working now...

(may help somebody)