Foren

How set setcontenttype in action mapping

Mahesh Narke, geändert vor 9 Jahren.

How set setcontenttype in action mapping

Regular Member Beiträge: 105 Beitrittsdatum: 11.10.13 Neueste Beiträge
Hi
Can anyone tell me how i can set content type using action response like resource Response?
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Mahesh Narke:
Hi
Can anyone tell me how i can set content type using action response like resource Response?



Hmm, must have missed that setContentType() method exposed in the ResourceResponse class...
Mahesh Narke, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping

Regular Member Beiträge: 105 Beitrittsdatum: 11.10.13 Neueste Beiträge
Is there any other way i can set the content type?
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
You mean like magic wand? Incantations?

No, that's how you set the content type. How else would you want to set it and why?
Mahesh Narke, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping

Regular Member Beiträge: 105 Beitrittsdatum: 11.10.13 Neueste Beiträge
David H Nebinger:
You mean like magic wand? Incantations?

If those kind of things works our life would have been very easy. emoticonemoticonemoticon
David H Nebinger:

No, that's how you set the content type. How else would you want to set it and why?

I am trying to perform internationalization (Arabic). It is working fine for English but for Arabic it encoding those values into ????????????????????????? or some other garbage values
thumbnail
David H Nebinger, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
Mahesh Narke:
I am trying to perform internationalization (Arabic). It is working fine for English but for Arabic it encoding those values into ????????????????????????? or some other garbage values


Hmm, content type is not supposed to be modified by localization... Content type is really just the mime type selection and, AFAIK, are not localizable (although I am not an I18N expert).

Locale should affect the content itself, but not the content type... Perhaps it's a Liferay bug? Which version of Liferay are you using?
Mahesh Narke, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping (Antwort)

Regular Member Beiträge: 105 Beitrittsdatum: 11.10.13 Neueste Beiträge
Version : liferay-portal-6.2-ee-sp5

Setcontenttype in action mapping:
HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(actionResponse);
httpResponse.setContentType("text/html; charset=UTF-8");


but this doesn't solve my problem of garbage content .
thumbnail
Juan Gonzalez, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping

Liferay Legend Beiträge: 3089 Beitrittsdatum: 28.10.08 Neueste Beiträge
Hi Maresh,

does this happen with any content in your portal?
Mahesh Narke, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping

Regular Member Beiträge: 105 Beitrittsdatum: 11.10.13 Neueste Beiträge
No. Facing this problem for textarea only.
I have one textarea on my jsp page and value we are getting is from our properties files.
There i am facing the issue at the time of arabic
thumbnail
Juan Gonzalez, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping

Liferay Legend Beiträge: 3089 Beitrittsdatum: 28.10.08 Neueste Beiträge
Ok, I remember some problems in CKEditor due to not adding -Dfile.encoding=UTF8 while starting up.

Can you read these instructions? https://www.liferay.com/documentation/liferay-portal/6.1/user-guide/-/ai/lp-6-1-ugen11-installing-liferay-on-tomcat-7-0 (specifically, the setenv.bat part).
Mahesh Narke, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping

Regular Member Beiträge: 105 Beitrittsdatum: 11.10.13 Neueste Beiträge
I have jboss.
I have tested on Tomcat.
I am getting proper arabic values on tomcat but not on jboss.
Need to implement for jboss as at this moment i can not move from jboss to tomcat
thumbnail
Juan Gonzalez, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping

Liferay Legend Beiträge: 3089 Beitrittsdatum: 28.10.08 Neueste Beiträge
Hi Mahesh,

don't be afraid of searching documentation! https://www.liferay.com/documentation/liferay-portal/6.1/user-guide/-/ai/installing-liferay

Check that you did all the steps properly for your Jboss version. In your case, be sure to add the right UTF encoding in standalone.conf.
Mahesh Narke, geändert vor 9 Jahren.

RE: How set setcontenttype in action mapping (Antwort)

Regular Member Beiträge: 105 Beitrittsdatum: 11.10.13 Neueste Beiträge
Mahesh Narke:
I am trying to perform internationalization (Arabic). It is working fine for English but for Arabic it encoding those values into ????????????????????????? or some other garbage values


Got the solution for this: Following are the changes i made :
in .jsp file :
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="ISO-8859-1" %>

In controller.java
actionRequest.setCharacterEncoding("UTF-8");
messageToCustomer=ParamUtil.getString(actionRequest, "messageToCustomer");
byte[] bytes = messageToCustomer.getBytes(StandardCharsets.ISO_8859_1);
messageToCustomer = new String(bytes, StandardCharsets.UTF_8);