Foros de discusión
p:fileDownload - ationListener AbortProcessingExcepeptin page renderd partl
andreas kehl, modificado hace 9 años.
p:fileDownload - ationListener AbortProcessingExcepeptin page renderd partl
New Member Mensajes: 17 Fecha de incorporación: 30/07/08 Mensajes recientes
Hello,
I want to use liferay-faces-1513-patch and have run some tests (so monitorDownload ist working thanks)
1)
I use:
Liferay: liferay-portal-6.1.1-ce-ga2
Primefaces: 5.0.10 / 5.1.13
JSF API/Impl: Mojarra JSF API (javax.faces/2.1) 2.1.29
Bridge patches Version 3.1.4-ga5:
liferay-faces-1513-patch
liferay-faces-1917-lsv-5-patch
liferay-faces-2006-patch
liferay-faces-2007-patch
liferay-faces-2056-patch
liferay-faces-2061-patch
---------------------------------------------------
2) from xhtml page
<p:commandButton ajax="false" value="Download File actionListener AbortExceptoion "
actionListener="#{LrPatchController.generateDetailedReport}">
<p:fileDownload value="#{LrPatchController.detailedReport}" />
</p:commandButton>
-------------------------------------------------
3) Backing Bean
@ManagedBean(name = "LrPatchController")
@ViewScoped
public class LrPatchController extends ViewController
{
......
public void generateDetailedReport(final ActionEvent ae)
{
LOG.debug("generateDetailedReport");
if (this.reportStream == null)
{
FacesMessageUtil.addGlobalErrorMessage(FacesContext.getCurrentInstance(), "message_success",
new String[] {"InputStream null / " + System.currentTimeMillis()});
throw new AbortProcessingException("InputStream null");
}
}
public StreamedContent getDetailedReport()
{
LOG.debug("getDetailedReport");
return new DefaultStreamedContent(this.reportStream, CommonConstants.EXPORT_MIME_TYPE_TXT, "file.txt");
}
....
4) In case of an Exception in ActionListener generateDetailedReport
the following URL is called
and the Portal Page is not rendered completly:
http://localhost:8080/web/guest/lr_patch_1513?p_p_id=portlet_test_lr_patch_WAR_sis_portlet_test&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&p_p_col_id=column-2&p_p_col_count=1&_portlet_test_lr_patch_WAR_sis_portlet_test__facesViewIdResource=%2Fviews%2Fportlet_test%2Flr_patch%2FtestFileViewMode.xhtml
5) see screenshot before / after attached
Any idea / solution appreciated
Thanks
Andreas
I want to use liferay-faces-1513-patch and have run some tests (so monitorDownload ist working thanks)
1)
I use:
Liferay: liferay-portal-6.1.1-ce-ga2
Primefaces: 5.0.10 / 5.1.13
JSF API/Impl: Mojarra JSF API (javax.faces/2.1) 2.1.29
Bridge patches Version 3.1.4-ga5:
liferay-faces-1513-patch
liferay-faces-1917-lsv-5-patch
liferay-faces-2006-patch
liferay-faces-2007-patch
liferay-faces-2056-patch
liferay-faces-2061-patch
---------------------------------------------------
2) from xhtml page
<p:commandButton ajax="false" value="Download File actionListener AbortExceptoion "
actionListener="#{LrPatchController.generateDetailedReport}">
<p:fileDownload value="#{LrPatchController.detailedReport}" />
</p:commandButton>
-------------------------------------------------
3) Backing Bean
@ManagedBean(name = "LrPatchController")
@ViewScoped
public class LrPatchController extends ViewController
{
......
public void generateDetailedReport(final ActionEvent ae)
{
LOG.debug("generateDetailedReport");
if (this.reportStream == null)
{
FacesMessageUtil.addGlobalErrorMessage(FacesContext.getCurrentInstance(), "message_success",
new String[] {"InputStream null / " + System.currentTimeMillis()});
throw new AbortProcessingException("InputStream null");
}
}
public StreamedContent getDetailedReport()
{
LOG.debug("getDetailedReport");
return new DefaultStreamedContent(this.reportStream, CommonConstants.EXPORT_MIME_TYPE_TXT, "file.txt");
}
....
4) In case of an Exception in ActionListener generateDetailedReport
the following URL is called
and the Portal Page is not rendered completly:
http://localhost:8080/web/guest/lr_patch_1513?p_p_id=portlet_test_lr_patch_WAR_sis_portlet_test&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&p_p_col_id=column-2&p_p_col_count=1&_portlet_test_lr_patch_WAR_sis_portlet_test__facesViewIdResource=%2Fviews%2Fportlet_test%2Flr_patch%2FtestFileViewMode.xhtml
5) see screenshot before / after attached
Any idea / solution appreciated
Thanks
Andreas
Archivos adjuntos:
Kyle Joseph Stiemann, modificado hace 9 años.
RE: p:fileDownload - ationListener AbortProcessingExcepeptin page renderd p
Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Andreas,
I cannot see where in your code you are setting this.reportStream. Could you post the code that sets this.reportStream?
I have tried to reproduce your error with similar code, but everything seems to be working for me. Perhaps you simply forgot to set this.reportStream in generateDetailedReport().
- Kyle
I cannot see where in your code you are setting this.reportStream. Could you post the code that sets this.reportStream?
I have tried to reproduce your error with similar code, but everything seems to be working for me. Perhaps you simply forgot to set this.reportStream in generateDetailedReport().
- Kyle
andreas kehl, modificado hace 9 años.
RE: p:fileDownload - ationListener AbortProcessingExcepeptin page renderd p
New Member Mensajes: 17 Fecha de incorporación: 30/07/08 Mensajes recientes
Hi Kyle,
I have simplified my test case.
I want to throw an exception in case of an error in generateDetailedReport( ..)
and reload the page somehow.
Means that I never set this.reportStream - it is NULL on purpose.
Means that getDetailedReport ist NOT called / report Stream is NULL)
Attached the simplified screens, xhtml page and java code.
In pfFileDownload12.png
- the Liferay Menue an page layout is broken
- the whole styles of the portlet are lost
Any Idea how to deal with exceptions in the ActionListener and reload the Page?
Thanks
Andreas
I have simplified my test case.
I want to throw an exception in case of an error in generateDetailedReport( ..)
and reload the page somehow.
Means that I never set this.reportStream - it is NULL on purpose.
Means that getDetailedReport ist NOT called / report Stream is NULL)
Attached the simplified screens, xhtml page and java code.
In pfFileDownload12.png
- the Liferay Menue an page layout is broken
- the whole styles of the portlet are lost
Any Idea how to deal with exceptions in the ActionListener and reload the Page?
Thanks
Andreas
Kyle Joseph Stiemann, modificado hace 9 años.
RE: p:fileDownload - ationListener AbortProcessingExcepeptin page renderd p
Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Could you try adding the following code in your actionListener?
BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
String facesViewId = bridgeContext.getFacesViewId();
String redirectURL = externalContext.encodeRedirectURL(facesViewId, null);
externalContext.redirect(redirectURL);
If that doesn't work, you could try this instead:
BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
PortletContainer portletContainer = bridgeContext.getPortletContainer();
String redirectURL = portletContainer.createRedirectURL(facesViewId, null);
externalContext.redirect(redirectURL);
Note: we will be removing and replacing PortletContainer in the future, so this method may not work in Liferay Faces GA6.
Please give those a try and let me know if they work.
- Kyle
BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
String facesViewId = bridgeContext.getFacesViewId();
String redirectURL = externalContext.encodeRedirectURL(facesViewId, null);
externalContext.redirect(redirectURL);
If that doesn't work, you could try this instead:
BridgeContext bridgeContext = BridgeContext.getCurrentInstance();
PortletContainer portletContainer = bridgeContext.getPortletContainer();
String redirectURL = portletContainer.createRedirectURL(facesViewId, null);
externalContext.redirect(redirectURL);
Note: we will be removing and replacing PortletContainer in the future, so this method may not work in Liferay Faces GA6.
Please give those a try and let me know if they work.
- Kyle
andreas kehl, modificado hace 9 años.
RE: p:fileDownload - ationListener AbortProcessingExcepeptin page renderd p
New Member Mensajes: 17 Fecha de incorporación: 30/07/08 Mensajes recientes
on
externalContext.redirect(redirectURL);
I get
Can only redirect during RESOURCE_PHASE if a JSF partial/Ajax request has been triggered
java.io.UnsupportedEncodingException: Can only redirect during RESOURCE_PHASE if a JSF partial/Ajax request has been triggered
see java code and logs attached
Andreas
externalContext.redirect(redirectURL);
I get
Can only redirect during RESOURCE_PHASE if a JSF partial/Ajax request has been triggered
java.io.UnsupportedEncodingException: Can only redirect during RESOURCE_PHASE if a JSF partial/Ajax request has been triggered
see java code and logs attached
Andreas
Archivos adjuntos:
Kyle Joseph Stiemann, modificado hace 9 años.
RE: p:fileDownload - ationListener AbortProcessingExcepeptin page renderd p
Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Andreas,
Sorry to have lead you wrong, but it turns out that this is an incompatibility between portlets and p:fileDownload (and similar components). p:fileDownload requires the form to specify that it will execute the RESOURCE_PHASE while a redirect requires that it not be in the RESOURCE_PHASE. To workaround this, you could either include your error message in the generated document or use two separate forms for generating the report and downloading the report.
- Kyle
Sorry to have lead you wrong, but it turns out that this is an incompatibility between portlets and p:fileDownload (and similar components). p:fileDownload requires the form to specify that it will execute the RESOURCE_PHASE while a redirect requires that it not be in the RESOURCE_PHASE. To workaround this, you could either include your error message in the generated document or use two separate forms for generating the report and downloading the report.
- Kyle