I have a popup which show the same page from which it was clicked . I have redirected it to another jsp but it does not show that jsp page but instead shows the same jsap page in the jsp .Below is the code . Thanks in advance
All the code below is in view.jsp
<portlet:defineObjects />
<script type="text/javascript">
var dialog2
function Popupdisplay1(url,flr){
alert(url);
AUI().use('aui-dialog', 'aui-io', function(A) {
alert("reached here inside popup");
dialog2 = new A.Dialog({
align:Liferay.Util.Window.ALIGN_CENTER,
title: 'My PopUp',
centered: true,
modal: true,
width: 550,
height: 400,
id: 'alert',
draggable: false,
resizable: false,
}).plug(A.Plugin.IO, {uri: url}).render();
});
}
</script>
<portlet:renderURL var="contractURL" windowState=<%=LiferayWindowState.EXCLUSIVE.toString()%>">
<portlet:param name="jspPage" value="" />
</portlet:renderURL>
<td><input class="notify" type="button" value="Notify"onclick="Popupdisplay1('<%=contractURL.toString()%>')"></td>
Related
I want to display two charts in PrimeFaces.
I am using Bootstrap 1.0.10, PrimeFaces 5.3 and Tomcat 7.
The strange thing is, that the chart is rendered, but the user isn't able to see it.
stats.xhtml
<ui:define name="content">
<div>
<p:panel id="panel" header="Statistik"
style="margin: 20px;">
<p:chart type="pie" model="#{statistikBean.chartModel1}"
style="width:400px; height:300px" />
<p:chart type="metergauge"
model="#{statistikBean.chartModel2}"
style="width:400px; height:250px" />
</p:panel>
</div>
</ui:define>
StatistikBean.java
....
private PieChartModel chartModel1;
private MeterGaugeChartModel chartModel2;
#PostConstruct
public void init() {
doModels();
}
private void doModels() {
this.chartModel1 = new PieChartModel();
// chartModel1
this.chartModel1.set("Fach 1", 10);
this.chartModel1.set("Fach 2", 20);
this.chartModel1.set("Fach 3", 30);
this.chartModel1.set("Fach 4", 40);
this.chartModel1.setTitle("Verteilung der Facher");
this.chartModel1.setLegendPosition("w");
// chartModel2
List<Number> intervall = new ArrayList<Number>(){{
add(50);
add(75);
add(85);
add(95);
}};
this.chartModel2 = new MeterGaugeChartModel(75, intervall);
this.chartModel2.setTitle("Fortschritt");
this.chartModel2.setSeriesColors("cc6666,E7E658,93b75f,66cc66");
this.chartModel2.setGaugeLabel("%");
}
.....
Rendered Output :
<div>
<div id="panel"
class="ui-panel ui-widget ui-widget-content ui-corner-all"
style="margin: 20px;"
data-widget="widget_panel">
<div id="panel_header" class="ui-panel-titlebar ui-widget-header ui-helper-clearfix ui-corner-all">
<span class="ui-panel-title">Statistik</span>
</div>
<div id="panel_content" class="ui-panel-content ui-widget-content">
<div id="j_idt17" style="width:400px; height:300px"></div>
<script id="j_idt17_s" type="text/javascript">
$(function () {
PrimeFaces.cw('Chart', 'widget_j_idt17', {
id: 'j_idt17',
type: 'pie',
data: [[["Fach 1", 10], ["Fach 2", 20], ["Fach 3", 30], ["Fach 4", 40]]],
title: "Verteilung der Facher",
legendPosition: "w",
datatip: true,
datatipFormat: "%s - %d"}, 'charts');
});
</script>
<div id="j_idt18" style="width:400px; height:250px"></div>
<script id="j_idt18_s" type="text/javascript">
$(function () {
PrimeFaces.cw('Chart', 'widget_j_idt18', {
id: 'j_idt18',
type: 'metergauge',
data: [[75]],
title: "Fortschritt",
seriesColors: ["#cc6666", "#E7E658", "#93b75f", "#66cc66"],
intervals: [50, 75, 85, 95],
gaugeLabel: "%",
gaugeLabelPosition: "inside",
showTickLabels: true,
labelHeightAdjust: -25}, 'charts');
});
</script>
</div>
</div>
<script id="panel_s" type="text/javascript">
PrimeFaces.cw("Panel", "widget_panel", {id: "panel"});
</script>
</div>
Tested it in Chrome and FireFox. The area where the chart(s) should be is just white.
Ok, I found the problem. I accidentally included jQuery two times.
One time in the JSF-template (with bootstrap), the second time with Primefaces.
I removed it from the JSF-template and it now works.
Is it possible to open pop up window from one portlet, that contains some other portlet ?
<portlet:renderURL var="kategorijaSelectorURL" windowState="<%= LiferayWindowState.POP_UP.toString() %>">
<portlet:param name="mvcPath" value="/html/kategorija/view.jsp" />
<portlet:param name="struts_action" value="/html/kategorija/view.jsp" />
<portlet:param name="tabs1" value="kategorije" />
<portlet:param name="redirect" value="<%=redirect1 %>" />
</portlet:renderURL>
yes you can.
var url;
function createRenderURL(portletId) {
AUI().ready('liferay-portlet-url', function(A) {
var renderURL = Liferay.PortletURL.createRenderURL();
renderURL.setName("test");
renderURL.setWindowState("pop_up");
renderURL.setPortletId(portletId);
url = renderURL.toString();
});
}
You can check below link for more deatails
Display portlet in pop-up Liferay
The idea is, create a URL of portlet which you want to invoke in popup and set window state to LiferayWindowState.POP_UP.toString()
update:
AUI().use('aui-dialog', 'aui-io', 'event', 'event-custom', function(A) {
dialog = new A.Dialog({
title: 'Title',
centered: true,
draggable: true,
resizable: false,
width: '980px',
height: '700px',
modal: true,
destroyOnClose: true
}).plug(A.Plugin.IO, {uri: '<%=urUrl%>'}).render();
dialog.show();
});
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
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.