Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Rendi Januar
Multiple Upload using Liferay.Upload problem?
10 de Dezembro de 2010 04:40
Resposta

Rendi Januar

Ranking: New Member

Mensagens: 13

Data de entrada: 6 de Dezembro de 2010

Mensagens recentes

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?
10 de Dezembro de 2010 21:45
Resposta

Anil Sunkari

Ranking: Expert

Mensagens: 427

Data de entrada: 11 de Agosto de 2009

Mensagens recentes

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?
16 de Dezembro de 2010 18:35
Resposta

Victor Kozlov

Ranking: New Member

Mensagens: 1

Data de entrada: 16 de Dezembro de 2010

Mensagens recentes

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?
16 de Dezembro de 2010 21:56
Resposta

Rendi Januar

Ranking: New Member

Mensagens: 13

Data de entrada: 6 de Dezembro de 2010

Mensagens recentes

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?
6 de Agosto de 2011 02:01
Resposta

Vasu S

Ranking: New Member

Mensagens: 1

Data de entrada: 6 de Agosto de 2011

Mensagens recentes

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?
8 de Outubro de 2011 09:12
Resposta

resmi Mathew

Ranking: New Member

Mensagens: 18

Data de entrada: 2 de Fevereiro de 2011

Mensagens recentes

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?
12 de Outubro de 2011 09:25
Resposta

Bakann DY

Ranking: New Member

Mensagens: 5

Data de entrada: 16 de Outubro de 2009

Mensagens recentes

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?
17 de Maio de 2012 06:05
Resposta

Yang bao

Ranking: New Member

Mensagens: 4

Data de entrada: 14 de Março de 2012

Mensagens recentes

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?
17 de Maio de 2012 06:34
Resposta

Yang bao

Ranking: New Member

Mensagens: 4

Data de entrada: 14 de Março de 2012

Mensagens recentes

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?
27 de Junho de 2012 05:17
Resposta

sheela mk

Ranking: Regular Member

Mensagens: 111

Data de entrada: 16 de Fevereiro de 2012

Mensagens recentes

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

for multiple File Upload..emoticon