xpages application layout: how to make logo clickable? - xpages

Is there a way to get the logo clickable when using the application layout? Most web sites go back to the home page when clicking the logo at the top, and my users are asking for this. Couldn't figure out how to it... I'm pretty sure it has to do with the submittedValue, but how do you set it for the logo? Or it may be something totally different, not sure.
I found this: onClick Event Banner in Application Layout but I am not sure I want to add some client side JavaScript to all pages. There must be a better way.

Add a class productLogoClass="applicationLogo" to your logo like shown here.
Add a client side onclick event for this class which executes a partial refresh on an empty panel. This panel has a rendered property which always returns true but executes additional code if partial refresh was executed by client side onclick event.
<xe:applicationLayout
...
<xe:this.configuration>
<xe:oneuiApplication
productLogo="/logo.png"
productLogoClass="applicationLogo">
...
</xe:oneuiApplication>
</xe:this.configuration>
</xe:applicationLayout>
<xp:eventHandler
event="onClientLoad"
submit="false">
<xp:this.script><![CDATA[var applicationLogo = dojo.query('.applicationLogo')[0];
applicationLogo.onclick = function() {
XSP.partialRefreshGet("#{id:onClickApplicationLogo}",
{params: {'onClickApplicationLogo': true}})
}
]]></xp:this.script>
</xp:eventHandler>
<xp:panel id="onClickApplicationLogo">
<xp:this.rendered><![CDATA[#{javascript:
if (param.onClickApplicationLogo) {
print("onClick application icon");
context.redirectToPage("Home.xsp");
}
return true;}]]>
</xp:this.rendered>
</xp:panel>
In this example it writes "onClick application icon" to server console and redirects to "Home.xsp".

Related

Client side javascript does not work

In my application I have a button:
<xp:button value="Say Hello" id="btnHello">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script>
<![CDATA[alert('Hello World!');]]>
</xp:this.script>
</xp:eventHandler>
</xp:button>
It generated this code:
<button class="xspButtonCommand" type="button" name="view:_id1:_id2:_id9:btnHello" id="view:_id1:_id2:_id9:btnHello">Say Hello</button>
<script type="text/javascript">
function view__id1__id2__id9__id28_clientSide_onclick(thisEvent) {
alert('bbbbbbb');
}
XSP.addOnLoad(function() {
XSP.attachEvent("view:_id1:_id2:_id9:_id28", "view:_id1:_id2:_id9:btnExport", "onclick", view__id1__id2__id9__id28_clientSide_onclick, false, 2);
});
</script>
When I click on the btnHello button, nothing happens. Does anyone know where the problem could be?
The problem was with third-party js library. I pasted it into a standard Notes javascript library and used it in xPage as a script resource. But Notes compiler or whatever it is could not resolve this library and therefore no script worked at all. Funny thing is that this library works fine in the normal web environment. Not in Notes environment.
So, problem solved. A third-party library is out and this particular script works all right, now. I guess IBM Notes with xPages is a real old school thing.

SSJS Codes behind the button runs after page is refreshed

I have SSJS code behind a button. When i click the button that code creates a document in another database.
When i click the button It Works fine but I look at the Domino Admin COnsole I realize that The code behind to button Works twice.. I think When the page is refreshed It Works again? How can i prevent it?
What is it thet I miss?
<xp:button value="Label" id="button1">
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:print("Before createNewDoc()");
createNewDoc();
print("After createNewDoc()");
}]]></xp:this.action>
</xp:eventHandler></xp:button>
Add print statements to the beforePageLoad, afterPageLoad etc events to confirm where it is running. Also, it's worth using XPages OpenLog Logger or some other logging framework that can output a full stack trace. That might identify whether the code is running twice in the refresh, and where from.
There is no reason the code should be running twice from the button. I'm assuming this is an SSJS function in a Script Library, maybe something else is triggering that.

Working dialog code from one application does not work in another application

I've working code to open dialog box using SSJS code to show error or warning to user when user click submit button. This button appears at the top of the xpage.
Applied the modified version of the above code in another application but instead of top of xpage, put button in section. If comboBox1 has initial value it is suppose to popup the dialog box. But it is not working. The client side validation is off in working as well as non working application. Why this code is not working? Where to check?
Here is code for a section button:
<xp:button value="Must click to Assign Quote Number" id="button6" style="width:207.0px">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="true">
<xp:this.action>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:var comboBox1:com.ibm.xsp.component.xp.XspSelectOneMenu = getComponent("comboBox1");
var a=comboBox1.getValue();
if ( a=="Assign the PE Staff"){
var d=getComponent('dialog2');
d.show();
}
}]]></xp:this.script>
</xp:executeScript>
</xp:this.action></xp:eventHandler>
</xp:button>
Things to check off the top of my head:
Check that Ext Lib is loaded properly in new app (check application properties)
Check that namespace for ExtLib is on the new page (drag any Ext Lib control on the page, and this will be added for you)
Check that resources from the first page are on the new one (script libraries, etc)
Try print("var a=" + a) to see if comboBox1 is giving you a value (check your server log.nsf)
If you give more info on what is happening when it doesn't work then we might be able to suggest more things to check.

Partial update dynamic view on CustomControl | XPages

I have an application with one XPage. It has these custom controls(cc):
ccHeader
ccMenu
ccContent
ccFooter
Custom control ccContent has a combobox, with list of Views in sessionScope and dynamic view panel from extension library for XPages. This combobox has an event OnChange defined to partial update dynamic view.
What do I need?: Combobox with view list will be deleted and after that I need to assign this partial update function to five links, which are located on ccMenu custom control. So, i click on link in ccMenu, it returns some view name, assigns it to dynamic view and makes partial update.
How to get id of this dynamic view in ccMenu to call partial update?
Assuming what you mean is that you want to have a clean way to let the buttons know which area to partial-refresh when changed:
You could add a property to the ccMenu control along the lines of "viewRefreshId" and pass in the ID of the area to refresh, so you'd end up with a button like this:
<xp:button id="viewChanger1" value="View 1">
<xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="${compositeData.viewRefreshId}">
<xp:this.action><![CDATA[#{javascript: viewScope.selectedView = 'View 1' }]]></xp:this.action>
</xp:eventHandler>
</xp:button>
Now, there's a question of whether you should try to pass in an ID from something contained within another CC from the main XPage, and I try to avoid that - it would PROBABLY work, but it's a bit messy. I tend to architect similar things so that the part to be refreshed is directly on the XPage (which is to say, I don't use "content" custom controls), so I end up with something like this:
<xc:viewSelector viewRefreshId="dynamicViewContainer"/>
<xp:div id="dynamicViewContainer">
<xe:dynamicView>
<xe:this.data>
<xp:dominoView var="view1" viewName="#{viewScope.selectedView}"/>
</xe:this.data>
</xe:dynamicView>
</xp:div>
The extra container div comes from experience that I had a while ago where refreshing the dynamic view directly caused rendering problems, but I don't know if that's still the case (or if I had run into some other problem).

onclick event of a radiobuttongroup does not fire after clearing sessionscope variables

Below is a simple Xpage with a radiobuttongroup that is bound to a sessionScope variable. The onclick event of the radio button group sets the computed field. There is an afterPageLoad event to initialize the session scope variable.
All works great. However, if I clear the session Scope variables (using the debug custom control) then the onclick event never fires. The user can click on the radio button all they want and the computed field never changes until the page is reloaded by pressing F5. Below is my page source. Any suggestions on how to get the onclick event to fire? This would be a big usability issue if the user let the session variables time out and then starting clicking on the radio button.
Howard
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.afterPageLoad><![CDATA[#{javascript:print("starting the afterPageLoad event");
if (sessionScope.init != true|| sessionScope.radioData == null){
//setup default values'
print("initing the value");
sessionScope.init = true;
sessionScope.radioData = "Red";
}
}]]></xp:this.afterPageLoad>
<xp:radioGroup id="radioButtons" value="#{sessionScope.radioData}">
<xp:selectItem itemLabel="Red"></xp:selectItem>
<xp:selectItem itemLabel="Green"></xp:selectItem>
<xp:selectItem itemLabel="Blue"></xp:selectItem>
<xp:eventHandler event="onclick" submit="true"
refreshMode="partial" refreshId="computedField1">
<xp:this.action><![CDATA[#{javascript:print("starting onclick event");
if (sessionScope.init != true){
print("reload the page");
context.reloadPage();
}
var radioval = getComponent("radioButtons").getValue();
getComponent("computedField1").setValue(radioval); }]]></xp:this.action>
</xp:eventHandler></xp:radioGroup>
<xp:text escape="true" id="computedField1"></xp:text></xp:view>
I've seen this same behavior several times in my own xpage apps, and I've found that the problem happens only for partial page refreshes where the target refreshId is not large enough in scope to reload all of the data needed by the control. When I change the refreshId to the page's main div (or use full page refresh), then all works as expected.
I think that it's the call to location.reload in the client-side code which is actually fixing your issue. I'd be interested to learn if increasing the scope of refreshId also fixes the problem.

Resources