Has anyone tried multiple file upload in Liferay 6.1. I was trying to do it the same way as it was in 6.0 and its failing badly. I see begin link on top left of the page and not withing portlet. When i click that and select some files, the control doesnt go to my portlet. I have checked my portlet.xml and verified the portlet-class is proper. Here's the snippet in jsp
<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>" windowState="pop_up" name="uploadFile" var="uploadFileURL" >
<portlet:param name="jspPage" value="/html/fileuploadportlet/view.jsp" />
</liferay-portlet:actionURL>
<div class="lfr-dynamic-uploader">
<div class="lfr-upload-container" id="<portlet:namespace />fileUpload"></div>
</div>
<div id="<portlet:namespace/>fallback"></div>
<aui:script use="liferay-upload">
new Liferay.Upload({
allowedFileTypes: '<%= StringUtil.merge(PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA)) %>',
container: '#<portlet:namespace />fileUpload',
maxFileSize: <%=Long.parseLong(PrefsPropsUtil.getString(PropsKeys.DL_FILE_MAX_SIZE)) %> / 1024,
namespace:'<%=renderResponse.getNamespace()%>',
uploadFile: '<%=uploadFileURL.toString()%>',
buttonHeight: 100,
buttonText: 'BEGIN',
buttonWidth: 100,
onFileComplete: function(){alert('fileComplete');},
onUploadError: function(){alert('error');}
});
</aui:script>
And here's the processAction method of my portlet
#Override
public void processAction(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, PortletException {
System.out.println("Something");
UploadPortletRequest uploadRequest=PortalUtil.getUploadPortletRequest(actionRequest);
File file =uploadRequest.getFile("file");
System.out.println(file.getName());
for(int i=0;i<50000;i++){
System.out.println("Something");
}
}
Can you check if your <aui:script> is correct, below is what is shown in html/portlet/document_library/upload_multiple_file_entries.jsp, I think you are missing the attribute tempFileURL:
<aui:script use="liferay-upload">
new Liferay.Upload(
{
allowedFileTypes: '<%= allowedFileExtensions %>',
container: '#<portlet:namespace />fileUpload',
deleteFile: '<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>"><portlet:param name="struts_action" value="/document_library/edit_file_entry" /><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.DELETE_TEMP %>" /><portlet:param name="folderId" value="<%= String.valueOf(folderId) %>" /></liferay-portlet:actionURL>&ticketKey=<%= ticket.getKey() %><liferay-ui:input-permissions-params modelName="<%= DLFileEntryConstants.getClassName() %>" />',
fileDescription: '<%= StringUtil.merge(PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA)) %>',
maxFileSize: '<%= PrefsPropsUtil.getLong(PropsKeys.DL_FILE_MAX_SIZE) %> B',
metadataContainer: '#<portlet:namespace />commonFileMetadataContainer',
metadataExplanationContainer: '#<portlet:namespace />metadataExplanationContainer',
namespace: '<portlet:namespace />',
tempFileURL: {
method: Liferay.Service.DL.DLApp.getTempFileEntryNames,
params: {
groupId: <%= scopeGroupId %>,
folderId: <%= folderId %>,
tempFolderName: 'com.liferay.portlet.documentlibrary.action.EditFileEntryAction'
}
},
uploadFile: '<liferay-portlet:actionURL doAsUserId="<%= user.getUserId() %>"><portlet:param name="struts_action" value="/document_library/edit_file_entry" /><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.ADD_TEMP %>" /><portlet:param name="folderId" value="<%= String.valueOf(folderId) %>" /></liferay-portlet:actionURL>&ticketKey=<%= ticket.getKey() %><liferay-ui:input-permissions-params modelName="<%= DLFileEntryConstants.getClassName() %>" />'
}
);
</aui:script>
Hope this helps.
Related
I have a theme where I have a popup to ask for the login credentials .
It has 2 fields ,login id and password followed by a submit button.
<div class="x">
<div class="y">
<aui:input name="login" id="login" class="z"
type="text" placeholder="Email" showRequiredLabel="<%=false%>" label="" value="<%=login%>">
</aui:input>
</div>
</div>
<div class="x">
<div class="y">
<aui:input name="password" id="Password"
class="z" type="password" placeholder="Password"
showRequiredLabel="<%=false%>" label="" value="<%=password%>">
</aui:input>
</div>
</div>
<div class="x">
<div class="y">
<aui:button-row>
<aui:button type="submit" class="btn z"
value="Log in" id=z/>
</aui:button-row>
</div>
</div>
<script>
jQuery(document).ready(function($) {
$('#z').click(function(){
var textBoxEmail= $('#login').val();
var textBoxPassword= $('#Password').val();
var redirecturl="/home";
var url = Liferay.ThemeDisplay.getPortalURL()+"/c/portal/login?login=" + textBoxEmail + "&password=" +textBoxPassword+"&rememberMe=false&redirect=" + redirecturl;
$("#loginDetails").attr('action',url);
document.getElementById('loginDetails').submit();
}
});
</script>
This logins for the positive case , but if the password or the email entered is incorrecet it displays the
"This webpage is not available
ERR_CONTENT_DECODING_FAILED"
I want to show the failure message in the same page from where i am sending the login details or I want it to be redirected to some URL if the authentication fails.
I am using liferay-6.2-ce-ga3 and the theme is designed in the velocity.
You could redirect to /c/portal/login?redirect=currenturl which redirects to the current url. Writing a Hook is another option if you want to customize more.
So before you even start I would question your design from an architectural standpoint. In Liferay, the login functionality is actually its own portlet (called the login portlet). The correct way to modify the login functionality is via a hook. However, to answer your question more directly, I would modify your code as such (most of this is taken from Liferay's login.jsp).
<portlet:actionURL secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" var="loginURL">
<portlet:param name="struts_action" value="/login/login" />
</portlet:actionURL>
<aui:form action="<%= loginURL %>" autocomplete='<%= PropsValues.COMPANY_SECURITY_LOGIN_FORM_AUTOCOMPLETE ? "on" : "off" %>' cssClass="sign-in-form" method="post" name="fm">
<aui:input name="saveLastPath" type="hidden" value="<%= false %>" />
<aui:input name="redirect" type="hidden" value="<%= redirect %>" />
<aui:input name="doActionAfterLogin" type="hidden" value="<%= portletName.equals(PortletKeys.FAST_LOGIN) ? true : false %>" />
<%
String loginLabel = null;
String authType = portletPreferences.getValue("authType", StringPool.BLANK);
if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
loginLabel = "email-address";
} else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
loginLabel = "screen-name";
} else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
loginLabel = "id";
}
%>
<aui:input autoFocus="<%= windowState.equals(LiferayWindowState.EXCLUSIVE) || windowState.equals(WindowState.MAXIMIZED) %>" cssClass="clearable" label="<%= loginLabel %>" name="login" showRequiredLabel="<%= false %>" type="text" value="<%= login %>">
<aui:validator name="required" />
</aui:input>
<aui:input name="password" showRequiredLabel="<%= false %>" type="password" value="<%= password %>">
<aui:validator name="required" />
</aui:input>
<span id="<portlet:namespace />passwordCapsLockSpan" style="display: none;"><liferay-ui:message key="caps-lock-is-on" /></span>
<aui:button-row>
<aui:button type="submit" value="sign-in" />
</aui:button-row>
</aui:form>
<aui:script use="aui-base">
var password = A.one('#<portlet:namespace />password');
if (password) {
password.on('keypress', function(event) {
Liferay.Util.showCapsLock(event, '<portlet:namespace />passwordCapsLockSpan');
});
}
</aui:script>
I agree, go with the Login hook or with authentication pipeline using pre and post login filters. The redirection can be done from filters.
Im trying to customize the login portlet for my purpose using this portlet login sample.
But when i login with test#liferay.com with a wrong password it shows "web page is not available"
SignInPortlet.java
public class SignInPortlet extends MVCPortlet {
#Override
public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {
String className = "com.liferay.portlet.login.action.LoginAction";
PortletConfig portletConfig = getPortletConfig();
NoRedirectActionResponse noRedirectActionResponse =
new NoRedirectActionResponse(actionResponse);
try {
PortletActionInvoker.processAction(
className, portletConfig, actionRequest,
noRedirectActionResponse);
}
catch (Exception e) {
_log.error(e, e);
}
String login = ParamUtil.getString(actionRequest, "login");
String password = ParamUtil.getString(actionRequest, "password");
String rememberMe = ParamUtil.getString(actionRequest, "rememberMe");
if (Validator.isNull(noRedirectActionResponse.getRedirectLocation())) {
actionResponse.setRenderParameter("login", login);
actionResponse.setRenderParameter("rememberMe", rememberMe);
}
else {
String redirect =
PortalUtil.getPathMain() + "/portal/login?login=" + login +
"&password=" + password + "&rememberMe=" + rememberMe;
actionResponse.sendRedirect(redirect);
}
}
private static Log _log = LogFactoryUtil.getLog(SignInPortlet.class);
}
View.jsp
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%# taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%# taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%# taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%# taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%# page import="com.liferay.portal.CookieNotSupportedException" %>
<%# page import="com.liferay.portal.NoSuchUserException" %>
<%# page import="com.liferay.portal.PasswordExpiredException" %>
<%# page import="com.liferay.portal.UserEmailAddressException" %>
<%# page import="com.liferay.portal.UserLockoutException" %>
<%# page import="com.liferay.portal.UserPasswordException" %>
<%# page import="com.liferay.portal.UserScreenNameException" %>
<%# page import="com.liferay.portal.kernel.language.LanguageUtil" %>
<%# page import="com.liferay.portal.kernel.util.ClassResolverUtil" %>
<%# page import="com.liferay.portal.kernel.util.Constants" %>
<%# page import="com.liferay.portal.kernel.util.GetterUtil" %>
<%# page import="com.liferay.portal.kernel.util.HtmlUtil" %>
<%# page import="com.liferay.portal.kernel.util.MethodKey" %>
<%# page import="com.liferay.portal.kernel.util.ParamUtil" %>
<%# page import="com.liferay.portal.kernel.util.PortalClassInvoker" %>
<%# page import="com.liferay.portal.kernel.util.PropsUtil" %>
<%# page import="com.liferay.portal.model.Company" %>
<%# page import="com.liferay.portal.security.auth.AuthException" %>
<%# page import="javax.portlet.WindowState" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<c:choose>
<c:when test="<%= themeDisplay.isSignedIn() %>">
<%
String signedInAs = user.getFullName();
if (themeDisplay.isShowMyAccountIcon()) {
signedInAs = "" + signedInAs + "";
}
%>
<%= LanguageUtil.format(pageContext, "you-are-signed-in-as-x", signedInAs, false) %>
</c:when>
<c:otherwise>
<%
MethodKey methodKey = new MethodKey(ClassResolverUtil.resolveByPortalClassLoader("com.liferay.portlet.login.util.LoginUtil"), "getLogin", HttpServletRequest.class, String.class, Company.class);
String login = GetterUtil.getString((String)PortalClassInvoker.invoke(false, methodKey, request, "login", company));
boolean rememberMe = ParamUtil.getBoolean(request, "rememberMe");
%>
<portlet:actionURL var="loginURL" />
<aui:form action="<%= loginURL %>" method="post" name="fm">
<aui:input name="saveLastPath" type="hidden" value="<%= false %>" />
<aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= Constants.UPDATE %>" />
<aui:input name="rememberMe" type="hidden" value="<%= rememberMe %>" />
<liferay-ui:error exception="<%= AuthException.class %>" message="authentication-failed" />
<liferay-ui:error exception="<%= CookieNotSupportedException.class %>" message="authentication-failed-please-enable-browser-cookies" />
<liferay-ui:error exception="<%= NoSuchUserException.class %>" message="please-enter-a-valid-login" />
<liferay-ui:error exception="<%= PasswordExpiredException.class %>" message="your-password-has-expired" />
<liferay-ui:error exception="<%= UserEmailAddressException.class %>" message="please-enter-a-valid-login" />
<liferay-ui:error exception="<%= UserLockoutException.class %>" message="this-account-has-been-locked" />
<liferay-ui:error exception="<%= UserPasswordException.class %>" message="please-enter-a-valid-password" />
<liferay-ui:error exception="<%= UserScreenNameException.class %>" message="please-enter-a-valid-screen-name" />
<table class="lfr-table">
<tr>
<td>
<aui:input name="login" style="width: 120px;" type="text" value="<%= HtmlUtil.escape(login) %>" />
</td>
</tr>
<tr>
<td>
<aui:input name="password" style="width: 120px;" type="password" value="" />
<span id="<portlet:namespace />passwordCapsLockSpan" style="display: none;"><liferay-ui:message key="caps-lock-is-on" /></span>
</td>
</tr>
<c:if test='<%= company.isAutoLogin() && !GetterUtil.getBoolean(PropsUtil.get("session.disabled")) %>'>
<tr>
<td>
<aui:input checked="<%= rememberMe %>" name="rememberMe" type="checkbox" />
</td>
</tr>
</c:if>
</table>
<br />
<input type="submit" value="<liferay-ui:message key="sign-in" />" />
</aui:form>
<c:if test="<%= renderRequest.getWindowState().equals(WindowState.MAXIMIZED) %>">
<aui:script>
Liferay.Util.focusFormField(document.<portlet:namespace />fm.<portlet:namespace />login);
</aui:script>
</c:if>
<aui:script use="aui-base">
A.one('#<portlet:namespace />password').on(
'keypress',
function(event) {
Liferay.Util.showCapsLock(event, '<portlet:namespace />passwordCapsLockSpan');
}
);
</aui:script>
</c:otherwise>
</c:choose>
Does any one know how to solve this?
I changed the portlet code like this .Now it is ok
public class SignInPortlet extends MVCPortlet {
#Override
public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {
String className = "com.liferay.portlet.login.action.LoginAction";
PortletConfig portletConfig = getPortletConfig();
NoRedirectActionResponse noRedirectActionResponse =
new NoRedirectActionResponse(actionResponse);
try {
PortletActionInvoker.processAction(
className, portletConfig, actionRequest,
noRedirectActionResponse);
}
catch (Exception e) {
_log.error(e, e);
}
String login = ParamUtil.getString(actionRequest, "login");
String password = ParamUtil.getString(actionRequest, "password");
String rememberMe = ParamUtil.getString(actionRequest, "rememberMe");
Object object = SessionErrors.get( actionRequest, AuthException.class.getName() );
if (( object != null ) || Validator.isNull(noRedirectActionResponse.getRedirectLocation())) {
actionResponse.setRenderParameter("login", login);
actionResponse.setRenderParameter("rememberMe", rememberMe);
}
else {
String redirect =
PortalUtil.getPathMain() + "/portal/login?login=" + login +
"&password=" + password + "&rememberMe=" + rememberMe;
actionResponse.sendRedirect(redirect);
}
}
private static Log _log = LogFactoryUtil.getLog(SignInPortlet.class);
}
I have a portlet in which there is a pop up .The content of the popup does not change but instead shows the same page from where it is clicked.When i click the notify button the popup shows but with the content of view.jsp.
All the code is present in view.jsp
<%#page import="com.mvantage.contract.model.Contract"%>
<%# include file="/init.jsp" %>
<portlet:defineObjects />
<%
PortletURL actionURL1=renderResponse.createActionURL();
actionURL1.setParameter(ActionRequest.ACTION_NAME,"navigateDashboard");
ArrayList<Contract> contractParameterList= (ArrayList<Contract>)renderRequest.getAttribute("contract");%>
<portlet:renderURL var="contractURL" windowState="<%= LiferayWindowState.POP_UP.toString()%>">
<portlet:param name="jspPage" value="/html/popup.jsp" />
</portlet:renderURL>
<script type="text/javascript">
alert("Inside new popup");
function showPopup() {
AUI().use('aui-dialog', 'aui-io', 'event', 'event-custom', function(A) {
var dialog = new A.Dialog({
title: 'Pop Up',
centered: true,
draggable: true,
modal: true,
width: 500,
height: 500,
}).plug(A.Plugin.IO, {uri: '<%= contractURL %>'}).render();
dialog.show();
});
}
<div id="container">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example4">
<thead>
<tr>
<th>a</th>
<th>b/th>
<th>c</th>
<th>d</th>
<th>e</th>
<th>f</th>
<th>g</th>
</tr>
</thead>
<tbody>
<%for(int i=0; i<contractParameterList.size(); i++ ){
Contract contractParameter = new Contract();
contractParameter = (Contract)contractParameterList.get(i);
%>
<tr class="odd gradeX">
<td><%=contractParameter.getAssetName()%></td>
<%actionURL1.setParameter("assetId",contractParameter.getAssetID());%>
<td><%=contractParameter.getAssetID()%></td>
<td><%=contractParameter.getCustomerName()%></td>
<td><%=contractParameter.getLocation()%></td>
<td><%=contractParameter.getRiskType()%></td>
<td><%=contractParameter.getContractNotificationTrigger()%></td>
<td><input class="notify" type="button" value="Notify" onclick="showPopup('<%=contractURL.toString()%>')"></td></tr> <%} %></tbody></table> <div style="clear:both;"></div></div>
The way you are using the A.Dialog it's not the best for me.
Try to use this way: http://alloyui.com/versions/1.7.x/examples/dialog/real-world/
Hi you can try below simplified code :
<aui:button value="Pop Up" icon="av-icon" iconAlign="left"
type="button" onClick="displayPopUp()" cssClass="notify" />
<script type="text/javascript">
function displayPopUp(){
Liferay.Util.openWindow({dialog: {width: 500,height: 500,destroyOnHide: true}, title: 'Pop Up', uri: '<%=contractURL%>
'
});
}
</script>
in this jsp i have displayed the popup when i click it on button using aui.. i want to display the text box value when i click it on the popup box can any one help me?.i dont know how to use pop.
<%# taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<div id="a">
<aui:input lable="enter name" name="name" type="text"></aui:input>
</div>
<div id="b">
<aui:button name="hello" value="click me" onclick='callPopup()'></aui:button>
</div>
<aui:script >
function callPopup(){
AUI().ready('aui-dialog', 'aui-overlay-manager', 'dd-constrain', function(A) {
alert('hai sudheer');
var dialog = new A.Dialog({
title: 'DISPLAY CONTENT',
centered: true,
modal: true,
draggable:true,
width: 300,
height: 300,
closeOnOutsideClick: true,
bodyContent: "This is testing content inside the popup"
}).render();
});
}
</aui:script >
<%# taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%# taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<aui:input lable="enter name" name="name" type="text" id="b"></aui:input>
<div id="a">
<aui:button name="hello" value="click me" onclick='callPopup()'></aui:button>
</div>
<portlet:namespace/>
<aui:script >
function callPopup(){
AUI().ready('aui-dialog', 'aui-overlay-manager', 'dd-constrain', function(A) {
var name = document.getElementById("_popexample_WAR_popupexampleportlet_b").value;
var sudheer="hai"+name;
alert('hai sudheer'+name);
var dialog = new A.Dialog({
title: 'DISPLAY CONTENT',
centered: true,
modal: true,
draggable:true,
width: 300,
height: 300,
bodyContent: sudheer
}).render();
});
}
</aui:script >
its working fine....tested...thanks
I am using my custom portlet in liferay.
but somehow when i run my portlet i m having following error in error console
Timestamp: 12/10/2012 12:33:19 PM
Error: ReferenceError: AUI is not defined
Source File: http://localhost:8080/eMenuAdvertise-portlet/js/jquery.min.js
Line: 4
Timestamp: 12/10/2012 12:34:21 PM
Error: ReferenceError: Liferay is not defined
Source File: http://localhost:8080/eMenuAdvertise-portlet/js/jquery.min.js
Line: 3
So why this error comes in my jsp page for some jquery?
<%# page import="net.sf.jasperreports.engine.JRException" %>
<%# page import="net.sf.jasperreports.engine.JasperExportManager" %>
<%# page import="net.sf.jasperreports.engine.JasperFillManager" %>
<%# page import="net.sf.jasperreports.engine.JasperPrint" %>
<%# page import="net.sf.jasperreports.engine.JasperPrintManager" %>
<%#page import="com.liferay.portal.model.Role"%>
<%# include file="/init.jsp"%>
<%#page import="com.liferay.portal.model.Organization"%>
<%#page import="com.liferay.portal.util.PortalUtil"%>
<style>
.borderColor{border: 1px solid #C62626;}
</style>
<portlet:renderURL var="ajaxaddnewrestURL">
<portlet:param name="jspPage" value="/jsps/ajaxnewrest.jsp" />
</portlet:renderURL>
<portlet:renderURL var="editrestURL">
<portlet:param name="jspPage" value="/jsps/Ajax_editrest.jsp" />
</portlet:renderURL>
<portlet:renderURL var="restListURL">
<portlet:param name="jspPage" value="/jsps/rest.jsp" />
</portlet:renderURL>
<portlet:renderURL var="reportURL">
<portlet:param name="jspPage" value="/htmlreport/report.html" />
</portlet:renderURL>
<portlet:renderURL var="renderURL ">
<portlet:param name="param-name" value="param-value" />
</portlet:renderURL>
<%-- <portlet:resourceURL var="ReportId" id="generate_report"></portlet:resourceURL> --%>
<portlet:resourceURL var="addToDo" id="generate_report"></portlet:resourceURL>
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/chosen/chosen.jquery.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.3/themes/south-street/ui.all.css" type="text/css">
<script src="<%=request.getContextPath()%>/js/datepickernew/jquery-1.8.3.js"></script>
<script src="<%=request.getContextPath()%>/js/datepickernew/jquery-ui.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.validate.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/lib/chosen/chosen.jquery.min.js"></script>
<%
System.setProperty("java.awt.headless", "true");
System.out.println(java.awt.GraphicsEnvironment.isHeadless());
String loading_img_path = request.getContextPath()+"/img/ajax_loader.gif";
boolean isReseller=false; ///advertiser if flag is false else Reseller
List<Role> role_list_page=themeDisplay.getUser().getRoles();
for(Role role_name:role_list_page){
if(role_name.getName().equals("Reseller")){
isReseller=true;
break;
}
}%>
<script>
</script>
<script>
$(function() {
$("#Start_validBeforeDatepicker").datepicker({
numberOfMonths: 1,
showButtonPanel: true,
onClose: function( selectedDate ) {
$( "#End_validAfterDatepicker" ).datepicker( "option", "minDate", selectedDate );
}
});
$("#End_validAfterDatepicker").datepicker({
numberOfMonths: 1,
showButtonPanel: true,
onClose: function( selectedDate ) {
$( "#Start_validBeforeDatepicker" ).datepicker( "option", "maxDate", selectedDate );
}
});
// $("#validBeforeDatepicker").datepicker({ minDate: 0 });
$('#Start_validBeforeDatepicker,#End_validAfterDatepicker').datepicker();
});
</script>
<script type="text/javascript">
$(".chzn-select").chosen();
$(".chzn-select-deselect").chosen({
allow_single_deselect : true
});
$(document).ready(function() {
$(".ui-datepicker").css("display","none");
});
</script>
<script type="text/javascript">
function update_rest(addToDo){
var camp_ID =document.getElementById('camp_id').value;
var f_start_date =document.getElementById('Start_validBeforeDatepicker').value;
var f_end_date =document.getElementById('End_validAfterDatepicker').value;
$.ajax({
url :addToDo,
data: {"rest_name":camp_ID,
"f_start_date":f_start_date,
"f_end_date":f_end_date,
"CMD":camp_ID},
type: "GET",
timeout: 20000,
dataType: "text",
success: function(data) {
alert("");
alert ( " liferay url : "+ Liferay.PortletURL.createRenderURL());
alert( "row1: " + createRowURL(1) );
alert( "row2: " + createRowURL(2) );
$("#mydiv").load("<%=renderURL.toString()%>");
alert(data);
}
});
}
function createRowURL( row ) {
var portletURL = new Liferay.PortletURL();
portletURL.setParameter("rowNumber", row );
return portletURL.toString();
}
function createRenderURL(str) {
alert("");
var renderURL = Liferay.PortletURL.createRenderURL();
alert("hi");
renderURL .setParameter("jspPage",str);
renderURL .setPortletId("eMenuAdvertise_WAR_eMenuAdvertiseportlet");
// i.e. your-unique-portlet-id can be like "helloworld_WAR_helloworldportlet"
}
</script>
<nav>
<div id="jCrumbs" class="breadCrumb module">
<ul>
<li><i class="icon-home"></i></li>
<li>Reseller</li>
<li>Restaurants</li>
</ul>
</div>
</nav>
<div class="row-fluid">
<div class="span12">
<div id="successMsg" style='display:none;' class="alert alert-success"></div>
<div id="errorMsg" style='display:none;' class="alert alert-error"></div>
<h3 class="heading">
Statistics
</h3>
<%String restId = request.getParameter("hide1");%>
<portlet:actionURL name="generateReport" var="reportURL"></portlet:actionURL>
</div>
<div class="">
<div class="">
<div class="">
<div style="float: right">
<p>
<label style="width: 100px"><b>Campaign</b></label>
</p>
<select id="camp_id" name="camp_id"
data-placeholder="- Select Restaurants -" class="chzn-select"
multiple><%
String status = null;
List<campaign> camp_listObj;
if(isReseller)
{
camp_listObj= campaignLocalServiceUtil.getAllCampaignByOrganizations(themeDisplay);
}
else
{
camp_listObj = campaignLocalServiceUtil.getAllCampaignByOrganizationId(themeDisplay);
}
for (int i = 0; i < camp_listObj.size(); i++) {
%>
<option value=<%=camp_listObj.get(i).getPrimaryKey()%>><%=camp_listObj.get(i).getName().toString()%></option>
<%
}
%>
</select>
</div>
<div style="float: left;">
<p>
<button onclick="update_rest('<%=addToDo%>');" class="btn btn-success">GenerateReports</button>
</p>
<b>Start Date</b> <input type="text" style="width: 100px"
id="Start_validBeforeDatepicker" name="validTodayDatepicker"
readonly="true"> <b>End Date</b> <input type="text"
readonly="true" style="width: 100px" id="End_validAfterDatepicker"
name="validAfterDatePicker">
</div>
</div>
</div>
<div style="visibility: hidden;">
<input type="hidden" name="report_path" id="report_path" value="">
</div>
<%
System.setProperty("java.awt.headless", "true");
System.out.println(java.awt.GraphicsEnvironment.isHeadless());
%>
</div>
</div>
<div class="bordercolor" id="mydiv">
</div>
<script type="text/javascript">
function editrestaurant(id){
$(".span12").html("<img class='ajax-loader' src='<%=loading_img_path%>'/>");
$.ajax({
type:'post',
url:'<%=editrestURL.toString()%>',
data:{restId:id},
success:function(data){
$(".main_content").html(data);
}
});
}
function newrestaurant(){
$(".span12").html("<img class='ajax-loader' src='<%=loading_img_path%>'/>");
$.ajax({
type:'post',
url:'<%=ajaxaddnewrestURL.toString() %>',
data:{},
success:function(data){
$(".main_content").html(data);
}
});
}
</script>
portlet.vm
#set ($portlet_display = $portletDisplay)
#set ($portlet_id = $htmlUtil.escapeAttribute($portlet_display.getId()))
#set ($portlet_title = $portlet_display.getTitle())
#set ($portlet_back_url = $htmlUtil.escapeAttribute($portlet_display.getURLBack()))
<section id="portlet_$portlet_id">
$portlet_display.writeContent($writer)
</section>
portal_normal.vm
#parse ($init)
<html class="#language("lang.dir")" dir="#language("lang.dir")" lang="$w3c_language_id">
<head>
</head>
<body class="$css_class">
<div id="wrapper">
<div id="content">
$theme.wrapPortlet("portlet.vm", $content_include)
</div>
</div>
</body>
$theme.include($bottom_include)
</html>
portal_popup.vm
<!DOCTYPE html>
#parse ($init)
<html dir="#language ("lang.dir")" lang="$w3c_language_id">
<head>
<title>$the_title</title>
$theme.include($top_head_include)
</head>
<body class="portal-popup $css_class">
$theme.include($content_include)
$theme.include($bottom_ext_include)
</body>
</html>
navigation.vm
<nav class="$nav_css_class" id="navigation">
<h1>
<span>#language("navigation")</span>
</h1>
<ul>
#foreach ($nav_item in $nav_items)
#if ($nav_item.isSelected())
<li class="selected">
#else
<li>
#end
<a href="$nav_item.getURL()" $nav_item.getTarget()><span>$nav_item.icon() $nav_item.getName()</span></a>
#if ($nav_item.hasChildren())
<ul class="child-menu">
#foreach ($nav_child in $nav_item.getChildren())
#if ($nav_child.isSelected())
<li class="selected">
#else
<li>
#end
<a href="$nav_child.getURL()" $nav_child.getTarget()>$nav_child.getName()</a>
</li>
#end
</ul>
#end
</li>
#end
</ul>
</nav>
In the <script> you have two javascript functions - createRowURL and createRenderURL which make use of the Alloy UI scripts as follows:
function createRowURL( row ) {
var portletURL = new Liferay.PortletURL(); // this is the line using AUI
portletURL.setParameter("rowNumber", row );
return portletURL.toString();
}
function createRenderURL(str) {
alert("");
var renderURL = Liferay.PortletURL.createRenderURL(); // this is the line using AUI
alert("hi");
renderURL .setParameter("jspPage",str);
renderURL .setPortletId("eMenuAdvertise_WAR_eMenuAdvertiseportlet");
// i.e. your-unique-portlet-id can be like "helloworld_WAR_helloworldportlet"
}
So I would suggest instead of using the <script> ... </script> tag use <aui:script> ... </aui:script> tags (this loads all the AUI and Liferay modules), for using this tag you would need to define the taglib in your jsp like:
<%# taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>`
Edit (after seeing the theme templates):
I can see that in your portal_normal.vm you have removed the following lines from <head> and <body> tags respectively:
$theme.include($top_head_include) <!-- this statement is removed from <head> -->
$theme.include($body_top_include) <!-- this statement is removed from <body> -->
Please include these statements back in the theme templates and your scripts would work. The statement $theme.include($top_head_include) this is responsible to include all the AUI related stuff (javascripts, functions etc) and also some variables in the request attribute.
Note: Please always be careful while removing anything from themes and hooks. You should always know what is the purpose of the statements you are removing or modifying.
Hope this helps.