Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Rendi Januar
Multiple Upload using Liferay.Upload problem?
December 10, 2010 4:40 AM
Answer

Rendi Januar

Rank: New Member

Posts: 13

Join Date: December 6, 2010

Recent Posts

Hi guys,

Currently I'm using Liferay 6.04 CE , and now I want to create Portlet Plugin using MVC Portlet like Image Gallery Portlet that liferay have.
And I've got problem when try to implement multiple upload that liferay have. It work properly until i click the button upload file. When i click the button upload, it won't go to action that i wrote. FYI i already success when the process using classic uploader (single upload).
Is there anything wrong in my code so it won't go to my action?
 1
 2new Liferay.Upload(
 3            {
 4                allowedFileTypes: '<%= StringUtil.merge(VirtualGalleryPrefsPropsUtil.getStringArray(PropsKeys.IG_IMAGE_EXTENSIONS, StringPool.COMMA)) %>',
 5                container: '#<portlet:namespace />fileUpload',
 6                fileDescription: '<%= StringUtil.merge(VirtualGalleryPrefsPropsUtil.getStringArray(PropsKeys.IG_IMAGE_EXTENSIONS, StringPool.COMMA)) %>',
 7                fallbackContainer: '#<portlet:namespace />fallback',
 8                maxFileSize: <%= VirtualGalleryPrefsPropsUtil.getLong(PropsKeys.IG_IMAGE_MAX_SIZE) %> / 1024,
 9                namespace: '<portlet:namespace />',
10                uploadFile: '<liferay-portlet:actionURL windowState="<%=LiferayWindowState.POP_UP.toString()%>" doAsUserId="<%=user.getUserId()%>" name="editImage"><portlet:param name="<%=Constants.CMD%>" value="<%=Constants.ADD%>" /><portlet:param name="folderId" value="<%=String.valueOf(folderId)%>" /></liferay-portlet:actionURL><liferay-ui:input-permissions-params modelName="<%=VGImage.class.getName()%>" />'
11            }
12        );

Is there anybody that have the same problem and already settle it?

Regards,
Rendi
Anil Sunkari
RE: Multiple Upload using Liferay.Upload problem?
December 10, 2010 9:45 PM
Answer

Anil Sunkari

Rank: Expert

Posts: 385

Join Date: August 11, 2009

Recent Posts

Hi Rendi,

I have a suggestion for your request.Before that i want to know that where you have placed the portlet.Exactly i mean is it in PRIVATE or PUBLIC PAGES.
B'coz very recently i have faced the same problem of accessing a class.But finally i clarified that it is not calling if we keep it in Public Pages.Plz chk the same with you.Let me know if you got the solution/idea.

Thanks
Anil Sunkari
Victor Kozlov
RE: Multiple Upload using Liferay.Upload problem?
December 16, 2010 6:35 PM
Answer

Victor Kozlov

Rank: New Member

Posts: 1

Join Date: December 16, 2010

Recent Posts

Hi.
I've run into the same issue recently. You may already solved it but I'll try to describe what I found out anyway:
Liferay is using SwfUpload that does not support currently opened http session. That means it opens a new one when a file is uploaded. This is a main reason to all below.

1) We have to specify 'doAsUserId' in liferay-portlet:actionURL to make it interact on behalf of particular user. If you look at PortalImpl.getUserId you'll see code that makes Liferay 'believe' that user specified correctly:
 1
 2        if (path.equals("/portal/session_click") ||
 3            strutsAction.equals("/document_library/edit_file_entry") ||
 4            strutsAction.equals("/image_gallery/edit_image") ||
 5            strutsAction.equals("/wiki/edit_page_attachment") ||
 6            actionName.equals("addFile")) {
 7
 8            alwaysAllowDoAsUser = true;
 9        }

So you should use one of these actions to allow invocation chain to continue.

2) The next key point is auth token checks that LayoutAction.processPortletRequest performs. As long as new session is created for upload they generally fail. But you can change 'auth.token.ignore.actions' property to add more actions there that do not require token ckecks. SessionAuthToken reads this property and ignore relevant actions.

Then your action should go...

I also use MVCPortlet without struts but the simpliest workaround was adding
<portlet:param name="struts_action" value="/image_gallery/edit_image" />
to liferay-portlet:actionURL. My action started to work.
Here is the line:
1
2uploadFile: '<liferay-portlet:actionURL windowState="pop_up" name="editImage" doAsUserId="<%= user.getUserId() %>"><portlet:param name="struts_action" value="/image_gallery/edit_image" /></liferay-portlet:actionURL>'
Rendi Januar
RE: Multiple Upload using Liferay.Upload problem?
December 16, 2010 9:56 PM
Answer

Rendi Januar

Rank: New Member

Posts: 13

Join Date: December 6, 2010

Recent Posts

Hi Victor,
Thanks for the reply,actually i already settle the problem like in your explanation, but i don't know the reason why it can be done like that, now i already know it from you emoticon

Thanks,
Rendi
Vasu S
RE: Multiple Upload using Liferay.Upload problem?
August 6, 2011 2:01 AM
Answer

Vasu S

Rank: New Member

Posts: 1

Join Date: August 6, 2011

Recent Posts

Hi Viktor,

I have a similar requirement & I tried out the same thing using MVCPortlet.
But I keep getting JSP error if I add <portlet:param name="struts_action" value="/image_gallery/edit_image" /> to my action URL tag.

This throws Jasper exception:
uploadFile: '<liferay-portlet:actionURL windowState="pop_up" name="editImage" doAsUserId="<%= user.getUserId() %>"><portlet:param name="struts_action" value="/image_gallery/edit_image" /></liferay-portlet:actionURL>'

This brings up the JSP, but action can't be associated:
uploadFile: '<liferay-portlet:actionURL windowState="pop_up" name="editImage" doAsUserId="<%= user.getUserId() %>"></liferay-portlet:actionURL>'

Any thoughts on this would be of great help, thx.

Thanks,
Vasu
resmi Mathew
RE: Multiple Upload using Liferay.Upload problem?
October 8, 2011 9:12 AM
Answer

resmi Mathew

Rank: New Member

Posts: 18

Join Date: February 2, 2011

Recent Posts

Thanks for explaining the solution here. I was facing problem with document library upload .I have used multi upload in my custom portlet and in my action class file name and folder Id values were coming null. By adding <portlet:param name="struts_action" value="/document_library/edit_file_entry" /> solved the issue.
Bakann DY
RE: Multiple Upload using Liferay.Upload problem?
October 12, 2011 9:25 AM
Answer

Bakann DY

Rank: New Member

Posts: 5

Join Date: October 16, 2009

Recent Posts

Victor Kozlov:

I also use MVCPortlet without struts but the simpliest workaround was adding
<portlet:param name="struts_action" value=" liferay-portlet:actionURL. My action started to work.
Here is the line:
1
2uploadFile: '<liferay-portlet:actionURL windowState="pop_up" name="editImage" doAsUserId="<%= user.getUserId() %>"><portlet:param name="struts_action" value="/image_gallery/edit_image" /></liferay-portlet:actionURL>'


Yes it works!! emoticonBut how did you find that trick???
If I understand, you simulate a call to the struts_action "/image_gallery/edit_image".
Yang bao
RE: Multiple Upload using Liferay.Upload problem?
May 17, 2012 6:05 AM
Answer

Yang bao

Rank: New Member

Posts: 4

Join Date: March 14, 2012

Recent Posts

Can you send me the whole portlet code. I don't know how to mapping the MVCPortlet Action.
Yang bao
RE: Multiple Upload using Liferay.Upload problem?
May 17, 2012 6:34 AM
Answer

Yang bao

Rank: New Member

Posts: 4

Join Date: March 14, 2012

Recent Posts

Can you send me the whole upload portlet code. I don't know how to mapping the MVCPortlet Action.

view.jsp :
new Liferay.Upload({
allowedFileTypes: '.jpg',
container: '#testaui_holder',
maxFileSize: 1024,
namespace:'',
uploadFile: '<liferay-portlet:actionURL windowState="pop_up"
name="updateSlogan" doAsUserId="<%=user.getUserId()%>">
<portlet:param name="struts_action" value="/image_gallery/edit_image" />
</liferay-portlet:actionURL>',
buttonHeight: 100,
buttonText: 'BEGIN',
buttonWidth: 100,
});

I have the "updateSlogan" In my SloganMvc class which extends MVCPortlet class
sheela mk
RE: Multiple Upload using Liferay.Upload problem?
June 27, 2012 5:17 AM
Answer

sheela mk

Rank: Regular Member

Posts: 112

Join Date: February 16, 2012

Recent Posts

Hai..All..If possible..Can You Please Let me know what the procedure..

for multiple File Upload..emoticon