[
https://jira.jboss.org/browse/GTNPORTAL-1340?page=com.atlassian.jira.plug...
]
Minh Hoang TO commented on GTNPORTAL-1340:
------------------------------------------
The type of FragementResponse returned in a portlet invocation depends on how portlet
developer does to generate output: writes chars to RenderResponse.getWriter() , writes
bytes to RenderResponse.getPortletOutputStream() or does nothing.
Below code snippet illustrate way to reproduce the issue with a simple JSR 168 portlet
@Override
protected void doEdit(RenderRequest request, RenderResponse response) throws
PortletException, IOException
{
//NullPointerException in Edit mode
//PrintWriter writer = response.getWriter();
//writer.write("Edit Hello World Portlet!");
//writer.close();
//No NullPointerException in Edit mode
OutputStream outputStream = response.getPortletOutputStream();
outputStream.write("Edit Hello World Portlet!".getBytes());
outputStream.close();
}
Portlet Edit mode is broken in Gatein 3.1 for JSF portlet
---------------------------------------------------------
Key: GTNPORTAL-1340
URL:
https://jira.jboss.org/browse/GTNPORTAL-1340
Project: GateIn Portal
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: WebUI
Affects Versions: 3.1.0-GA
Environment: All
Reporter: Gerbert Nuijen
Assignee: Minh Hoang TO
Fix For: 3.2.0-GA
Original Estimate: 1 hour
Remaining Estimate: 1 hour
The edit mode for jsf portlets is broken in Gatein 3.1. This was introduced with bug fix
https://jira.jboss.org/browse/GTNPORTAL-1228.
The problem is that FragmentResponse has either chars or bytes:
public int getType()
{
if (bytes == null)
{
if (chars == null)
{
return TYPE_EMPTY;
}
else
{
return TYPE_CHARS;
}
}
else
{
return TYPE_BYTES;
}
}
/**
* Return the content as a string.
*
* @return the content
*/
public String getContent()
{
switch (getType())
{
case TYPE_CHARS:
return getChars();
case TYPE_BYTES:
return new String(bytes);
case TYPE_EMPTY:
return "";
default:
throw new AssertionError();
}
}
The correct fix should be something like this:
FragmentResponse fragmentResponse = (FragmentResponse)portletResponse;
if (fragmentResponse.getType() == FragmentResponse.TYPE_BYTES) {
content = new String(fragmentResponse.getBytes(), "UTF-8");
} else {
content = fragmentResponse.getContent();
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira