on 08-22-2014 7:29 PM
Hello Experts,
I have worte this Code:
public class PopupIview extends AbstractPortalComponent {
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response) {
IUser user = request.getUser();
INotificationRule rule = new NewsNotificationRule();
PopupBean ruleBean = new PopupBean();
request.getServletRequest().setAttribute("rule", ruleBean);
//fill your bean with data here...
ruleBean.setMessage(rule.getMessage(user));
IResource html = request.getResource(IResource.JSP,"pagelet/popup_ui.jsp");
response.include(request, html);
}
}
and this JSP-Page starting with this
<HTML>
<jsp:useBean id="rule" scope="request" class="ui.PopupBean" />
But while executing this, in the JSP-Page the rule-Bean is empty. I saw that it has an other Obejct-ID. So why my Bean from the portal application isn't used?
Thanks and Greetings,
Thomas
So after some month, reading the right documentation and some playing with the source, I found the reason. I think my source code I've pasted was the correct, but I tested with a wrong one.
When you add a bean to a request or the context, the key you use must be the same, as the ID in the JSP. That seems not right for me, but only when these two values are equal, the JSP receives the bean-object I added in the servlet.
Here are the both importent lines from the source:
in the Servlet
request.getServletRequest().setAttribute("rule", ruleBean);
in the JSP
<jsp:useBean id="rule" scope="request" class="ui.PopupBean" />
Greetings
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas,
Your code seems fine to me.
Which NW version are you on?
Where is the JSP code the outputs the data?
BR,
Saar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Saar,
ok the Problem is half gone. When I debug, the bean has now the right values, but while using the bean,
NovaDialogBox.createMessageDialogBox("Benachrichtigung", <%rule.getMessage();%>, "Ok", 127, 124)
print an empty String in the HTML-File. I think, there are problems in my understanding of the JSP-Material.
For understanding, I try to build an message dialog, using the AFP-NovaDialogBox with a Message generated with informations out of the portal environment. For this I wrote this HTML-Page:
<HTML>
<jsp:useBean id="rule" scope="request" class="ui.PopupBean" />
<script type="text/javascript" src="/scripts/afp_ui.js"></script>
<script type="text/javascript">
function onLoad() {
if(window.EPCM){
window.EPCM.subscribeEvent('urn:com.sapportals:navigation', 'AFPisLoaded', init);
}
else {
init();
}
}
function init() {
NovaDialogBox.createMessageDialogBox("Benachrichtigung", <%rule.getMessage();%>, "Ok", 127, 124)
}
</script>
<body onload="onLoad" />
</HTML>
I am realy confused about all this. The portalapp.xml looks like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<application>
<application-config>
<property name="SharingReference" value="usermanagement, knowledgemanagement"/>
<property name="Vendor" value="de.fub"/>
</application-config>
<components>
<component name="PopupIview">
<component-config>
<property name="ClassName" value="ui.PopupIview"/>
<property name="SecurityZone" value="PopupIview/low_safety"/>
</component-config>
<component-profil/>
</component>
</components>
<services/>
</application>
BR,
Thomas
Hello Saar,
yes you are right, it was the '=' to declare an expression. But then at the end the ';' is forbidden. So the right line must be
NovaDialogBox.createMessageDialogBox("Benachrichtigung", "<%= rule.getMessage() %>", "Ok", 127, 124)}.
So the last Problem is, that the rule.getMessage() returns a String with \n included. The JSP-Interpreter do for this a linebreak, that i dont't want. The \n-characters should be written down to the JS-Script.
BR,
Thomas
Hi Thomas,
This is where XSSEncoder class comes to play:
SAP Encoding Functions for AS Java and JavaScript - Secure Programming - SAP Library
BR,
Saar
Hello Saar,
so my last Question is, I placed the IView of the PortalApplication in the Technical Hidden iViews Container of the Ajax Framework Page and for a nother try in the Masthead Container. In both version there is no functional problem. But the Layout isn't correct.
The iframe class=coverArea, don't has the full width (1325px), while the the coverArea of the logout dialog has the full width (1343px). The picture should show the problem on the right side?
The Logout dialog looks like this.
There is no cap on the right side.
The calculation of the width can be found in the
coverAreaElement.display = function(G) of the afp_ui.js file. The function call attributes = getCoverAreaAttributes( attributes ); where the document.body.scrollWidth is used as width. An ther ist the strange behavior. When it is called the first time, it returns 1325px, but after this call, it returns the correct value of 1343px. It seems, the the body isn't fully loaded. So where do I have to include the IView, that this doesn't happen.
I tried a little hack and call document.body.scrollWidth befor creating the Dialog, but this doesn't do the job. When I debug the script and wait to long, document.body.scrollWidth get me the right width. Any Ideas?
I should mantion, that this is only a IE Problem. In Firefox the coverarea has the right width.
Greetings,
Thomas
Ah ok,
I use the SAP AFP-UI Framework and only call NovaDialog.createMessageDialogBox(...). More I can't do. I debug it and the framework is calculating the width of the coverarea with document.body.scrollWidth. So my question was, if I had to place my IView in the AFP-Frameworkpage at a special place, so that the framework will get the right width.
The IView has the following Code
<jsp:useBean id="rule" scope="request" class="ui.PopupBean" />
<%! String newline = System.getProperty("line.separator"); %>
<script type="text/javascript">
var onLoad = function() {
NovaDialogBox.createMessageDialogBox("Benachrichtigung", "<%= rule.getMessage().replaceAll(newline,"</br>") %>", "Ok", 267, 124);
}
if (window.EPCM) {
EPCM.subscribeEventReliable("urn:com.sapportals.portal:browser","load", onLoad);
}
</script>
Thanks and Greetings,
Thomas
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.