Matias
Matias

Reputation: 45

Liferay: how can i upload a image from portlet preferences?

Using liferay 6.2, I'm currently trying to create a portlet where a image is displayed.

I have already done this but I need to be able to change the image from the preferences uploading a new one. I already have a form to upload a file but I'm not able to upload the file and show it on the portlet.

This is the form in the edit.jsp

<aui:form action="<%=editPreferencesURL%>" method="post">
<aui:input label="image" name="Image" type="file"/>
<aui:button type="submit" />
</aui:form>

This is the renderURL:

<portlet:renderURL var="editPreferencesURL">
   <portlet:param name="mvcPath" value="/html/folder/edit.jsp" />
</portlet:renderURL>

Upvotes: 1

Views: 786

Answers (1)

Olaf Kock
Olaf Kock

Reputation: 48067

The editPreferencesURL that you mention is a renderURL - for posting a form you'll need an actionURL.

A renderURL is typically used to show the raw form (e.g. it's fine to use it to link to the edit mode form) but not for updating data. During render a portlet cannot change state, during action it can.

Upvotes: 1

Related Questions