Bonjour à tous,
Ayant galéré sur la version 6.0.6 de Liferay pour faire fonctionner le portlet iFrame avec authentification en méthode POST, je pensais être tranquille avec la nouvelle version 6.1.0 ... hé ben non
Re-belote : grattage de tête + bidouillage + plusieurs cafés => je vous livre ci-dessous les modifs à effectuer pour faire fonctionner ce portlet.
Prérequis :- Ubuntu
- Liferay 6.1.0-ce-ga1 (le bundle de Liferay)
- Tomcat-7.0.23
Je l'ai installé dans /usr/local/
Localisation :/usr/local/liferay-portal-6.1.0-ce-ga1/tomcat-7.0.23/webapps/ROOT/html/portlet/iframe
Cette localisation est à moduler suivant votre installation la partie qui ne change pas étant : [...]/webapps/ROOT/html/portlet/iframe
Ce dossier contient normalement :
- css(folder)
- configuration.jsp
- init.jsp
- proxy.jsp
- view.jsp
Les modifs:Dans le configuration.jsp- ligne 83 : remplacer formUserName par userName
- ligne 96 : remplacer formPassword par password
configuration.jsp après modifs :
1<%--
2/**
3 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License as published by the Free
7 * Software Foundation; either version 2.1 of the License, or (at your option)
8 * any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 * details.
14 */
15--%>
16
17<%@ include file="/html/portlet/iframe/init.jsp" %>
18
19<%
20String redirect = ParamUtil.getString(request, "redirect");
21
22String htmlAttributes =
23 "alt=" + alt + "\n" +
24 "border=" + border + "\n" +
25 "bordercolor=" + bordercolor + "\n" +
26 "frameborder=" + frameborder + "\n" +
27 "hspace=" + hspace + "\n" +
28 "longdesc=" + longdesc + "\n" +
29 "scrolling=" + scrolling + "\n" +
30 "title=" + title + "\n" +
31 "vspace=" + vspace + "\n";
32%>
33
34<liferay-portlet:actionURL portletConfiguration="true" var="configurationURL" />
35
36<aui:form action="<%= configurationURL %>" method="post" name="fm">
37 <aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= Constants.UPDATE %>" />
38 <aui:input name="redirect" type="hidden" value="<%= redirect %>" />
39
40 <liferay-ui:panel-container extended="<%= true %>" id="iframeSettingsPanelContainer" persistState="<%= true %>">
41 <liferay-ui:panel collapsible="<%= true %>" extended="<%= true %>" id="iframeGeneralPanel" persistState="<%= true %>" title="general">
42 <aui:fieldset>
43 <aui:input cssClass="lfr-input-text-container" label="source-url" name="preferences--src--" prefix='<%= relative ? "..." : StringPool.BLANK %>' type="text" value="<%= src %>" />
44
45 <aui:input label="relative-to-context-path" name="preferences--relative--" type="checkbox" value="<%= relative %>" />
46 </aui:fieldset>
47 </liferay-ui:panel>
48
49 <liferay-ui:panel collapsible="<%= true %>" extended="<%= true %>" id="iframeAuthenticationPanel" persistState="<%= true %>" title="authenticate">
50 <aui:fieldset>
51 <aui:input label="authenticate" name="preferences--auth--" type="checkbox" value="<%= auth %>" />
52
53 <div id="<portlet:namespace />authenticationOptions">
54 <div class="portlet-msg-info" id="<portlet:namespace />currentLoginMsg">
55 <c:choose>
56 <c:when test="<%= IFrameUtil.isPasswordTokenEnabled(renderRequest) %>">
57 <liferay-ui:message key="you-may-use-the-tokens-email-address-screen-name-userid-and-password" />
58 </c:when>
59 <c:otherwise>
60 <liferay-ui:message key="you-may-use-the-tokens-email-address-screen-name-userid" />
61 </c:otherwise>
62 </c:choose>
63 </div>
64
65 <aui:select label="authentication-type" name="preferences--authType--">
66 <aui:option label="basic" selected='<%= authType.equals("basic") %>' />
67 <aui:option label="form" selected='<%= authType.equals("form") %>' />
68 </aui:select>
69
70 <div id="<portlet:namespace />formAuthOptions">
71 <aui:select name="preferences--formMethod--">
72 <aui:option label="get" selected='<%= formMethod.equals("get") %>' />
73 <aui:option label="post" selected='<%= formMethod.equals("post") %>' />
74 </aui:select>
75
76 <aui:field-wrapper label="user-name">
77 <table class="lfr-table">
78 <tr>
79 <td>
80 <aui:input cssClass="lfr-input-text-container" label="field-name" name="preferences--userNameField--" type="text" value="<%= userNameField %>" />
81 </td>
82 <td>
83 <aui:input cssClass="lfr-input-text-container" label="value" name="preferences--userName--" type="text" value="<%= userName %>" />
84 </td>
85 </tr>
86 </table>
87 </aui:field-wrapper>
88
89 <aui:field-wrapper name="password">
90 <table class="lfr-table">
91 <tr>
92 <td>
93 <aui:input cssClass="lfr-input-text-container" label="field-name" name="preferences--passwordField--" type="text" value="<%= passwordField %>" />
94 </td>
95 <td>
96 <aui:input cssClass="lfr-input-text-container" label="value" name="preferences--password--" type="text" value="<%= password %>" />
97 </td>
98 </tr>
99 </table>
100
101 <aui:input cssClass="lfr-input-text-container" name="hiddenVariables" type="text" value="<%= hiddenVariables %>" />
102 </aui:field-wrapper>
103 </div>
104
105 <div id="<portlet:namespace />basicAuthOptions">
106 <aui:input cssClass="lfr-input-text-container" label="user-name" name="preferences--basicUserName--" type="text" value="<%= userName %>" />
107
108 <aui:input cssClass="lfr-input-text-container" label="password" name="preferences--basicPassword--" type="text" value="<%= password %>" />
109 </div>
110 </div>
111 </aui:fieldset>
112 </liferay-ui:panel>
113
114 <liferay-ui:panel collapsible="<%= true %>" extended="<%= true %>" id="iframeDisplaySettingsPanel" persistState="<%= true %>" title="display-settings">
115 <aui:fieldset>
116 <aui:input label="resize-automatically" name="preferences--resizeAutomatically--" type="checkbox" value="<%= resizeAutomatically %>" />
117
118 <div id="<portlet:namespace />displaySettings">
119 <aui:input name="preferences--heightMaximized--" type="text" value="<%= heightMaximized %>" />
120 <aui:input name="preferences--heightNormal--" type="text" value="<%= heightNormal %>" />
121 <aui:input name="preferences--width--" type="text" value="<%= width %>" />
122 </div>
123
124 <aui:input cssClass="lfr-textarea-container" name="preferences--htmlAttributes--" onKeyDown="Liferay.Util.checkTab(this); Liferay.Util.disableEsc();" type="textarea" value="<%= htmlAttributes %>" wrap="soft" />
125 </aui:fieldset>
126 </liferay-ui:panel>
127 </liferay-ui:panel-container>
128
129 <aui:button-row>
130 <aui:button type="submit" />
131 </aui:button-row>
132</aui:form>
133
134<aui:script>
135 <c:if test="<%= windowState.equals(WindowState.MAXIMIZED) || windowState.equals(LiferayWindowState.POP_UP) %>">
136 Liferay.Util.focusFormField(document.<portlet:namespace />fm.<portlet:namespace />src);
137 </c:if>
138
139 Liferay.Util.toggleBoxes('<portlet:namespace />authCheckbox','<portlet:namespace />authenticationOptions');
140 Liferay.Util.toggleBoxes('<portlet:namespace />resizeAutomaticallyCheckbox','<portlet:namespace />displaySettings', true);
141 Liferay.Util.toggleSelectBox('<portlet:namespace />authType', 'form', '<portlet:namespace />formAuthOptions');
142 Liferay.Util.toggleSelectBox('<portlet:namespace />authType', 'basic', '<portlet:namespace />basicAuthOptions');
143</aui:script>
Dans le view.jsp- ligne 50 : ajouter:
if(authType.equals("form")){
String monpId= portletDisplay.getId();
iframeSrc = "/c/iframe/proxy?p_l_id="+plid+"&p_p_id="+monpId+"&";
}
view.jsp après modifs :
1
2<%--
3/**
4 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by the Free
8 * Software Foundation; either version 2.1 of the License, or (at your option)
9 * any later version.
10 *
11 * This library is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 * details.
15 */
16--%>
17
18<%@ include file="/html/portlet/iframe/init.jsp" %>
19
20<%
21String iframeSrc = StringPool.BLANK;
22
23if (relative) {
24 iframeSrc = themeDisplay.getPathContext();
25}
26
27iframeSrc += (String)request.getAttribute(WebKeys.IFRAME_SRC);
28
29if (Validator.isNotNull(iframeVariables)) {
30 if (iframeSrc.indexOf(StringPool.QUESTION) != -1) {
31 iframeSrc = iframeSrc.concat(StringPool.AMPERSAND).concat(StringUtil.merge(iframeVariables, StringPool.AMPERSAND));
32 }
33 else {
34 iframeSrc = iframeSrc.concat(StringPool.QUESTION).concat(StringUtil.merge(iframeVariables, StringPool.AMPERSAND));
35 }
36}
37
38String baseSrc = iframeSrc;
39
40int lastSlashPos = iframeSrc.substring(7).lastIndexOf(StringPool.SLASH);
41
42if (lastSlashPos != -1) {
43 baseSrc = iframeSrc.substring(0, lastSlashPos + 8);
44}
45
46String iframeHeight = heightNormal;
47
48if (windowState.equals(WindowState.MAXIMIZED)) {
49 iframeHeight = heightMaximized;
50}
51if(authType.equals("form")){
52 String monpid = portletDisplay.getId();
53 iframeSrc = "/c/iframe/proxy?p_l_id="+plid+"&p_p_id="+monpid+"&";
54}
55%>
56
57<c:choose>
58 <c:when test="<%= auth && Validator.isNull(userName) && !themeDisplay.isSignedIn() %>">
59 <div class="portlet-msg-info">
60 <a href="<%= themeDisplay.getURLSignIn() %>" target="_top"><liferay-ui:message key="please-sign-in-to-access-this-application" /></a>
61 </div>
62 </c:when>
63 <c:otherwise>
64 <div>
65 <iframe alt="<%= alt %>" border="<%= border %>" bordercolor="<%= bordercolor %>" frameborder="<%= frameborder %>" height="<%= iframeHeight %>" hspace="<%= hspace %>" id="<portlet:namespace />iframe" longdesc="<%= longdesc%>" name="<portlet:namespace />iframe" onload="<portlet:namespace />monitorIframe();" scrolling="<%= scrolling %>" src="<%= iframeSrc %>" title="<%= title %>" vspace="<%= vspace %>" width="<%= width %>">
66 <%= LanguageUtil.format(pageContext, "your-browser-does-not-support-inline-frames-or-is-currently-configured-not-to-display-inline-frames.-content-can-be-viewed-at-actual-source-page-x", iframeSrc) %>
67 </iframe>
68 </div>
69 </c:otherwise>
70</c:choose>
71
72<aui:script>
73 function <portlet:namespace />monitorIframe() {
74 var url = null;
75
76 try {
77 var iframe = document.getElementById('<portlet:namespace />iframe');
78
79 url = iframe.contentWindow.document.location.href;
80 }
81 catch (e) {
82 return true;
83 }
84
85 var baseSrc = '<%= baseSrc %>';
86 var iframeSrc = '<%= iframeSrc %>';
87
88 if ((url == iframeSrc) || (url == iframeSrc + '/')) {
89 }
90 else if (Liferay.Util.startsWith(url, baseSrc)) {
91 url = url.substring(baseSrc.length);
92
93 <portlet:namespace />updateHash(url);
94 }
95 else {
96 <portlet:namespace />updateHash(url);
97 }
98
99 return true;
100 }
101
102 Liferay.provide(
103 window,
104 '<portlet:namespace />init',
105 function() {
106 var A = AUI();
107
108 var hash = document.location.hash.replace('#', '');
109
110 var hashObj = A.QueryString.parse(hash);
111
112 hash = hashObj['<portlet:namespace />'];
113
114 if (hash) {
115 var src = '';
116
117 if (!(/^https?\:\/\//.test(hash))) {
118 src = '<%= baseSrc %>';
119 }
120
121 src += hash;
122
123 var iframe = A.one('#<portlet:namespace />iframe');
124
125 if (iframe) {
126 iframe.attr('src', src);
127 }
128 }
129 },
130 ['aui-base', 'querystring']
131 );
132
133 Liferay.provide(
134 window,
135 '<portlet:namespace />updateHash',
136 function(url) {
137 var A = AUI();
138
139 var hash = document.location.hash.replace('#', '');
140
141 var hashObj = A.QueryString.parse(hash);
142
143 hashObj['<portlet:namespace />'] = url;
144
145 var maximize = A.one('#p_p_id<portlet:namespace /> .portlet-maximize-icon a');
146
147 hash = A.QueryString.stringify(hashObj);
148
149 if (maximize) {
150 var href = maximize.attr('href');
151
152 href = href.split('#')[0];
153
154 maximize.attr('href', href + '#' + hash);
155 }
156
157 var restore = A.one('#p_p_id<portlet:namespace /> a.portlet-icon-back');
158
159 if (restore) {
160 var href = restore.attr('href');
161
162 href = href.split('#')[0];
163
164 restore.attr('href', href + '#' + hash);
165 }
166
167 location.hash = hash;
168 },
169 ['aui-base', 'querystring']
170 );
171
172 <portlet:namespace />init();
173</aui:script>
174
175<aui:script use="aui-resize-iframe">
176 var iframe = A.one('#<portlet:namespace />iframe');
177
178 if (iframe) {
179 iframe.plug(
180 A.Plugin.ResizeIframe,
181 {
182 monitorHeight: <%= resizeAutomatically %>
183 }
184 );
185
186 iframe.on(
187 'load',
188 function() {
189 var height = A.Plugin.ResizeIframe.getContentHeight(iframe);
190
191 if (height == null) {
192 height = <%= heightNormal %>;
193
194 if (themeDisplay.isStateMaximized()) {
195 height = <%= heightMaximized %>;
196 }
197
198 iframe.setStyle('height', height);
199
200 iframe.resizeiframe.set('monitorHeight', false);
201 }
202 }
203 );
204
205 }
206</aui:script>
Please sign in to flag this as inappropriate.