how to recuperate the list of the potlet created in liferay 6.2 using java - liferay-hook

My problem is to recuperate the list of the portlet created in liferay 6.2
without display the default portlet in liferay 6.2.
i try this code
<%
boolean includeSystemPortlets = false;
List<Portlet> portlets = PortletLocalServiceUtil.getPortlets(company.getCompanyId(), includeSystemPortlets, false);
portlets = ListUtil.sort(portlets, new PortletTitleComparator(application, locale));
for (Portlet curPortlet : portlets) {
if (Validator.isNull(curPortlet.getPortletId()) || hiddenPortletIds.contains(curPortlet.getPortletId())) {
continue;
}
editPermissionsURL.setParameter("portletResource", curPortlet.getPortletId());
%>
but it display all the portlet created and the default portlet
i want to change this code : " List portlets = PortletLocalServiceUtil.getPortlets(company.getCompanyId(), includeSystemPortlets, false); " because it display all the portlet

Related

Failed to add saved page to menu bar - wrapper application using electron

I recently follow a project electron on geeksforgeeks: https://www.geeksforgeeks.org/create-a-geeksforgeeks-wrapper-application-using-electron/
Here is its code on Github https://github.com/sayantanm19/geeksforgeeks-desktop/blob/master/index.js
The function appenItemToMenu doesn't work, which means I could save pages offline but the savedpagelist on menu bar is always empty ...
Could you try it on your machine and point out the bug?
function appendItemToMenu(filename) {
curr_menu = Menu.getApplicationMenu()
.getMenuItemById("saved").submenu
curr_menu.append(
new MenuItem({
label: path.basename(filename, '.html'),
click() {
console.log('Saved page opened')
win.loadFile(savedFolder + path.basename(filename))
}
}))
}
function appendItemToMenu(filename) {
const newMenu = Menu.getApplicationMenu()
curr_menu = newMenu.getMenuItemById('saved').submenu
curr_menu.append(
new MenuItem({
label: path.basename(filename, '.html'),
click() {
console.log('Saved page opened')
win.loadFile(savedFolder + path.basename(filename))
}
}))
Menu.setApplicationMenu(newMenu)
}
Update the application menu after change. Any dynamic change or append Item not allowed.

Rotativa ViewAsPdf not executing jquery

I'm using Rotativa (v1.6.4) for converting an MVC view into a PDF. I have used jQuery in the View to show/hide certain text content.
When I render the View, I see that jQuery is working, but when I render viewaspdf, the jquery is not working.
I have added --debug-javascript --no-stop-slow-scripts --javascript-delay 10000 but this looks to be not working. Can someone help me here?
Here is Controller detail:
public ActionResult PrintBenificiaryForm()
{
PrintBenificiary p = new PrintBenificiary();
p.TeamMemberInfo = GetSessionValues();
p.IndividualBenefitPlans = GetBenefitPlansandIndividuals();
string customSwitches = string.Format("--debug-javascript --no-stop-slow-scripts --javascript-delay 10000 --footer-left \"[page] of [toPage]\" --footer-spacing -10 --footer-font-size \"10\" --header-html \"{0}\" ", Url.Action("PrintHeader", "Home", null, this.Request.Url.Scheme));
return new ViewAsPdf("PrintBenificiaryForm", p)// { FileName = p.TeamMemberInfo.FirstName + " " + p.TeamMemberInfo.LastName + ".pdf" };
{
CustomSwitches = customSwitches
};
//return View(p);
}
I faced the same issue. I resolved this by editing 'qt.browser' in the 'App_Browsers' folder. It was created by Rotativa during the installing package from NuGet. I changed capability with name="javascriptversion" from 1.7 to my version of jquery - 3.1.1. And this resolved my issue. Hope this help someone

Kentico 9 - Separate MVC Application - Document Attachment

I am trying to add an attachment to a document - I am running a separate MVC application - not part of the same solution as the Kentico admin site.
I am getting error site not found for my UserInfo.
public Models.PartnerUpdateModel NewPartnerUpdate(Models.PartnerUpdateModel partnerupdatemodel)
{
CMS.DocumentEngine.TreeNode newpartnerupdatetreenode = CMS.DocumentEngine.TreeNode.New(partnerupdatemodel.KenticoPartnerUpdate.ClassName);
TreeProvider tree = new TreeProvider();
partnerupdatemodel.KenticoPartnerUpdate.Title = partnerupdatemodel.Title;
partnerupdatemodel.KenticoPartnerUpdate.Summary = partnerupdatemodel.Summary;
partnerupdatemodel.KenticoPartnerUpdate.Article = partnerupdatemodel.Article;
partnerupdatemodel.KenticoPartnerUpdate.Author = partnerupdatemodel.MarketConnectUser.UserID.ToString();
partnerupdatemodel.KenticoPartnerUpdate.DocumentCulture = partnerupdatemodel.DocumentCulture;
partnerupdatemodel.KenticoPartnerUpdate.Insert(TreeHelper.SelectSingleNode(partnerupdatemodel.MarketConnectUser.DefaultGroup.GroupChildNodes.Where(x => x.Key == partnerupdatemodel.ParentClassName).Select(x => x.Value).Single()), true);
partnerupdatemodel.KenticoPartnerUpdate.SubmitChanges(true);
foreach (var file in partnerupdatemodel.Files)
{
HttpPostedFile postedfile = FileHelper.ConstructHttpPostedFile(FileHelper.ToByteArray(file.InputStream), file.FileName, file.ContentType);
DocumentHelper.AddAttachment(newpartnerupdatetreenode, Models.PartnerUpdateModel.AttachmentColumnNames.Image.ToString(), postedfile, new TreeProvider(MembershipContext.AuthenticatedUser)); //GETTING ERROR HERE
newpartnerupdatetreenode.Update();
}
return partnerupdatemodel;
}
MembershipContext is not oficially supported in v9 (Supported and unsupported Kentico features on MVC sites) however I think this should work - to be honest I have tried it by myself and I`ve got UserInfo (for public user and global admin too). Could you please provide call stack of exception?
edit: I have also tried to get current SiteInfo like
var site = SiteContext.CurrentSite;
and it`s null if you have not specified Presentation URL - could you check this setting?

Vaadin File Uploading using FileFilter

I am Using Vaadin Framework. I need to Upload Files in the format of PDF,JAR & ZIP only. I tried with this code.This code is also I got from STACK OVER FLOW.
public void uploadStarted(StartedEvent event) {
// TODO Auto-generated method stub
System.out.println("***Upload: uploadStarted()");
ArrayList<String> allowedMimeTypes = new ArrayList<String>();
allowedMimeTypes.add("application/java-archive");
allowedMimeTypes.add("application/pdf");
allowedMimeTypes.add("application/zip");
String contentType = event.getMIMEType();
boolean allowed = false;
System.out.println(":::::::::::::contentType::::::"
+ contentType);
for (int i = 0; i < allowedMimeTypes.size(); i++) {
if (contentType.equalsIgnoreCase(allowedMimeTypes.get(i))) {
allowed = true;
break;
}
}
try {
if (allowed) {
System.out.println("boolean value:::::::allowed"
+ allowed);
finalDeedUpload.setReceiver(finalDeedFileUploadHandler);
finalDeedUpload.addListener(finalDeedFileUploadHandler);
} else {
showWarningNotification(
"Error:Please Upload File in Given Format", "");
}
This is working for while uploading PDf files it's working, while uploading Zip OR Jar file and any other file it is showing NULLPOINTER EXCEPTION.
Please help me.
Vaadin has a special upload component which is easy to use. There is a whole chapter in Book of Vaadin related to this component.
https://vaadin.com/book/-/page/components.upload.html
In Vaadin 14 there is a method setAcceptedFileTypes at class Upload:
MemoryBuffer buffer = new MemoryBuffer();
Upload upload = new Upload(buffer);
upload.setAcceptedFileTypes(new String[]{"application/zip", "application/pdf", "application/java-archive"});
The method setAcceptedFileTypes sets the HTML attribute accept at the <input type="file"> element and therefore limits / filters what the application user can upload.

Open report in new tab using jasper plugin in grails

I am using jasper plugin to generate my report. All is fine but except my pdf is opening on the current tab, when I want to open it in a new tab.
I have no idea how to do it. Can anybody please help me on this please?
I am using "i-report" to design my pdf. Here is my code below :
def index = {
println(params)
def testModel = this.getProperties().containsKey('chainModel') ?
chainModel : null
JasperReportDef report = null
if (params.containsKey('auto_print_dialog')){
report = docuJasperService.buildReportDefinition(params,
request.getLocale(), testModel)
}
else{
report = jasperService.buildReportDefinition(params,
request.getLocale(), testModel)
}
generateResponse(report)
}
def generateResponse = {reportDef ->
if (!reportDef.fileFormat.inline && !reportDef.parameters._inline) {
//response.characterEncoding = "UTF-8"
//response.setHeader("Content-disposition",
//"inline; filename=${params._name}");
response.setHeader("Content-disposition", "inline;
filename="+(reportDef.parameters._name ?: reportDef.name) +
"."+reportDef.fileFormat.extension);
response.contentType = "application/pdf"
response.outputStream << reportDef.contentStream.toByteArray()
} else {
render(text: reportDef.contentStream, contentType:
reportDef.fileFormat.mimeTyp,
encoding: reportDef.parameters.encoding ?
reportDef.parameters.encoding : 'UTF-8');
}
}
This is going to be handled by the link you use to generate the report. Typically adding a target of _blank will do the trick. For example:
<g:link controller="myReports" action="whateverReport" target="_blank">Click for your report</g:link>
This will open the link in a new tab.
If you are using a form adding target to the form will submit the form to a new tab. For example:
<form name="myForm" action="whateverReport" method="POST" target="_blank">
or
<g:form name="myForm" controller="myReports" action="whateverReport" target="_blank">
You could even do so with javascript window.open if you needed, but I will leave that example out of this answer as it's well documented elsewhere.

Resources