Dialog Framework doesn't work

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
anabpz
Posts: 12
Joined: 25 Nov 2015, 19:32

06 Sep 2017, 12:22

Hi!
I write here because I'm using Barcelona 1.0.1 theme with Primefaces 6.1.4 version.

I have problems trying to use Dialog Framework. I have followed all details about configuration that figures in the manual and I 've made a simple xhtml page to open it in a dialog. Indeed, I have same problem as this question https://stackoverflow.com/questions/275 ... og-to-work. I can execute without problems
"RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(
FacesMessage.SEVERITY_INFO, "TEST", "It's a test."));"
but I don't understand why I can't execute other method from the instance.

My code files are the following:
application.xml

Code: Select all

	<action-listener>org.primefaces.application.DialogActionListener</action-listener>
	<navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
	<view-handler>org.primefaces.application.DialogViewHandler</view-handler>
page that has the command to execute openDialogTest():

Code: Select all

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:enova="http://java.sun.com/jsf/composite/enova"
                template="/xhtml/include/template.xhtml">
                
    <ui:define name="content">
    	<p:commandButton value="DIALOG FRAMEWORK"
				icon="fa fa-check"
				actionListener="#{mymanagedBean.openDlgTest}"/>
    </ui:define>
</ui:composition>
page to show into dialog: test.xhtml

Code: Select all

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>TEST</title>
</h:head>
<h:body>
		<strong>This is a test</strong>
</h:body>
</html>
managedBean method from it executes open dialog: myManageBean.java

Code: Select all

/** For test Dialog Framework */
	public void openDlgTest() {
	//Dialog Framework		
	Map<String,Object> options = new HashMap<String, Object>();
        options.put("modal", true);
        options.put("width", 640);
        options.put("height", 340);
        options.put("contentWidth", "100%");
        options.put("contentHeight", "100%");
        options.put("headerElement", "customheader");
	        
        RequestContext.getCurrentInstance().openDialog("test", options, null);
        
//      //Business logic (It works)
//        RequestContext.getCurrentInstance().showMessageInDialog(new FacesMessage(
//        		FacesMessage.SEVERITY_INFO, "TEST", "It's a test."));
	}
Moreover, in section <h:head> of my template.xhtml I added the following, but without results.

Code: Select all

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:sec="http://www.springframework.org/security/facelets/tags">

    <h:head>
    	<h:outputScript library="primefaces" name="jquery/jquery.js" />
    </h:head>
    
    [...]
When I click on the commandButton I can see how appears ajax message "Please wait a moment" but then nothing happens.
Last edited by anabpz on 08 Sep 2017, 08:50, edited 2 times in total.
PrimeFaces 11.0 | JSF 2.3 | Barcelona Theme 5.0.0

anabpz
Posts: 12
Joined: 25 Nov 2015, 19:32

07 Sep 2017, 12:40

One annotation more,

If I modify test.xhtml page (to show in Dialog Framework) with some wrong snippet, I can show it but it redirects to my error.jsp page.

error.jsp

Code: Select all

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page isErrorPage="true"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
	"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/resources/css/main.css" />
</head>

<body>
	<div style="min-height:100%; height: auto!important; height:100%; background-color: white;">
		<div style="height: 40px; position: relative; z-index: 10; background-color: #000000;">
			<img src="<%=request.getContextPath()%>/resources/images/logo.png" 
				width="105" class="linkImage" style="margin-top: 5px; margin-left: 8px;"/>
		</div>
		<div style="padding-top: 0;">
			<div>
				<table id="cuerpo">
					<tr>
						<td><img
							src="<%=request.getContextPath()%>/resources/images/warning.png" /></td>
						<td>
							<table>
								<tr>
									<td>There has been an error</td>
								</tr>
								<tr>
									<td><b>The requested page could not be loaded, or well does not exist</b></td>
								</tr>
								<tr>
									<td><hr /></td>
								</tr>
								<tr>
									<td><a href="<%=request.getContextPath()%>"> Click here to go back to the beginning. </a></td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</body>
</html>
PrimeFaces 11.0 | JSF 2.3 | Barcelona Theme 5.0.0

anabpz
Posts: 12
Joined: 25 Nov 2015, 19:32

08 Sep 2017, 09:37

I have just testing from other browsers like Firefox. On Firefox I get open a dialog but without any content, so the next step has been to open 'Console mode' by clicking 'F12' and I've got this error:

Code: Select all

Load denied by X-Frame-Options: http://localhost:8080/mywebapp/xhtml/test.jsf?pfdlgcid=f35e6793-eba4-401e-b84f-41d6f649f112 does not permit framing.
So searching on Internet, I 've found this clue https://stackoverflow.com/questions/286 ... g-security

I use Spring Security, so that has been the problem.
I added to my securityCtx.xhtml configuration file this:

Code: Select all

<sec:http use-expressions="true">
		<sec:intercept-url pattern="/*" access="permitAll" />
		<sec:intercept-url pattern="/xhtml/**" access="hasAnyRole('ROLE_BASIC', 'ROLE_ADMIN')" />
		<sec:form-login login-page="/login.jsf" />
		<sec:csrf disabled="true" />
		<sec:headers>
			<sec:frame-options policy="SAMEORIGIN"/>
		</sec:headers>
		<sec:access-denied-handler error-page="/error/error" />
	</sec:http>
I hope this can help others with similar problems.

Regards!
PrimeFaces 11.0 | JSF 2.3 | Barcelona Theme 5.0.0

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

19 Sep 2017, 08:32

Thanks a lot for the update, @anabpz.

gayeous
Posts: 4
Joined: 16 Jul 2014, 10:39

02 Aug 2019, 20:46

Merci

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

05 Aug 2019, 13:53

;)

Post Reply

Return to “Barcelona - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests