SharePoint DelegateControl Render Order - sharepoint

I have two SharePoint features, each implemented identically (see below), that add controls to a delegate control in the header of my pages. One of the controls depends on the other (one is the jQuery library, and the other depends upon jQuery), however, when the controls are rendered, the order of the controls is incorrect. How do I specify the order that these controls are rendered in?
The control (both are identical, except that they reference a different .js file):
<%# Control ClassName="MyScriptControl" %>
<script type="text/javascript" src="/_layouts/MyScript.js"></script>
feature.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="AA9D59AC-D53E-4338-9B52-CD39F2A8C31A"
ActivateOnDefault="true"
Title="My Feature"
Description="Does something."
Scope="Site" Version="1.0.0.0"
Hidden="FALSE"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="MyFeature\Elements.xml" />
</ElementManifests>
</Feature>
Elements.xml:
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"
Id="24A4BB9A-9636-4a73-B3A5-35661DE19902">
<Control Id="AdditionalPageHead"
ControlSrc="~/_controltemplates/MyControl.ascx" />
</Elements>
The output on the page (jQuery is deployed before DependsOnjQuery):
<script type="text/javascript" src="/_layouts/DependsOnjQuery.js"></script>
<script type="text/javascript" src="/_layouts/jQuery.min.js"></script>
I want MyControl1.js to render before MyControl2.js.

I was able to get this to work by adding a second DelegateControl to the header of my masterpage, and adding jQuery to that delegate. This way, I can make sure that jQuery will always load before everything else, without having to write some logic to delay the loading of my dependant libraries.
<SharePoint:DelegateControl runat="server" ControlId="jQueryDelegate" AllowMultipleControls="true"/>
<SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>

It looks to me like the Sequence attribute can be used to control the order in which these guys are rendered. Give your jQuery control a sequence of 50 and your DependsOnjQuery control a sequence of 100 and you should be good.
See the Delegate Control documentation on MSDN for more info.

did you try and set the DEFER="DEFER" attribute on the script.
that would tell the user agent that the script should wait for the page to load and render before it loads the script.
Else you could hack it by setting a variable at the one script, that is set to true when script is loaded. In the other you placed logic that tested (think loop and timeout method) if the script was loaded and then calls your logic when both scripts are loaded.
not very nice, but you need some kind of logic to handle execution, and not just run the methods inline in your script.
To nathan: sequences in delegates are used to determine which of the delegate controls to load. This should have nothing to do with the issue in question. As i understand it the JS files just set the value on a script that just happens to be a delegate control.

Related

How can I add custom search engine to browser?

Basically what I'm trying to do is to be able to add my own "search engine" (based on PHP and Mod_rewrite) to any browser automatically.
Somewhere on the Internet I found that I need to declare a search provider. How can I do this? <link>, manifest or some JavaScript?
A couple of steps. First, create an XML file with the information for the search provider. This is an example for Wikipedia: (Named: Wikipedia.xml)
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Wikipedia</ShortName>
<Description>Wikipedia Search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" template="http://en.wikipedia.org/w/index.php?title={searchTerms}" />
</OpenSearchDescription>
Then you need to call the Windows method to add it. I do it with a button element like so but you could call the method how ever you prefer.
<input type="button" value="Add Wikipedia Search Provider" onClick='window.external.AddSearchProvider("Wikipedia.xml");'>

Has anyone successfully implemented the dojox.mobile.carousel in XPages

I have a requirement for an application in a Domino version 9.x deployment for a carousel like interface similar to what Netflix and others use to allow continuous scrolling. I got the jQuery jCarousel code working from here. But that lacks the pizzazz the user wants since the swiping feature is not available. I also used 100% computed HTML instead of being able to intersperse XPages controls within the carousel code.
So I found dojox/mobile/carousel (examples here) but all implementations, including the basic examples are not working well. The number of elements does not seem to be flexible and the positioning of them is much lower than I would think the should be. I fiddled with the CSS to see if I could fix things but have not found the right combination.
Here is the entire custom control I am using for this test (I captured the images from the demo and added them as image resources):
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core"
dojoParseOnLoad="true">
<xp:this.resources>
<xp:metaData
name="viewport"
content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
</xp:metaData>
<xp:metaData
name="apple-mobile-web-app-capable"
content="yes">
</xp:metaData>
<xp:styleSheet
href="/.ibmxspres/dojoroot/dojox/mobile/themes/iphone/iphone.css">
</xp:styleSheet>
<xp:dojoModule
name="dojox/mobile"></xp:dojoModule>
<xp:dojoModule
name="dojox/mobile/parser"></xp:dojoModule>
<xp:dojoModule
name="dojox/mobile/Carousel"></xp:dojoModule>
</xp:this.resources>
<xp:panel>Above it</xp:panel>
<div
id="carousel1"
data-dojo-type="dojox/mobile/Carousel"
data-dojo-props='height:"150px", navButton:false, numVisible:2, title:"Category"'>
<!-- View #1 -->
<div
data-dojo-type="dojox/mobile/SwapView">
<div
data-dojo-type="dojox/mobile/CarouselItem"
data-dojo-props='src:"dish1.jpg", value:"dish", headerText:"dish"'></div>
<div
data-dojo-type="dojox/mobile/CarouselItem"
data-dojo-props='src:"glass1.jpg", value:"glass", headerText:"glass"'></div>
</div>
<!-- View #2 -->
<div
data-dojo-type="dojox/mobile/SwapView">
<div
data-dojo-type="dojox/mobile/CarouselItem"
data-dojo-props='src:"stone1.jpg", value:"stone", headerText:"stone"'></div>
<div
data-dojo-type="dojox/mobile/CarouselItem"
data-dojo-props='src:"shell1.jpg", value:"shell", headerText:"shell"'></div>
</div>
</div>
<xp:panel>Below it</xp:panel>
</xp:view>
in the sample in the documentation it has this comment followed by the inclusion of a JavaScript file.
<!-- Need to load the theme files for Carousel and PageIndicator as well as the base theme file -->
<script type="text/javascript" src="dojox/mobile/deviceTheme.js"
data-dojo-config="mblThemeFiles: ['base','Carousel','PageIndicator']"></script>
Not having this step done may be my problem but I cannot see how to do that within the XPages environment.
The dojo carousel exists since 1.7 Notes 8.5.3 comes with 1.6 (i dont know the dojo version of Notes9), so you maby have to update your dojo or implement a newer dojo lib in your application.
I did a short experiment on it, i disabled the build in dojo adding xsp.client.script.libraries=none to my xsp.properties and importet the dojo 1.9 in my application under WEB-INF/dojo/... then add the dojo to my xPage as ClientSide script resource. As soon i finished this the programatic Example from the dojo homepage worked immediately with out bigger errors (forgot to change the image sources =) ..).
The problem when adding xsp.client.script.libraries=none to your xsp.properties is that you also disable the XSP. library and some other xPage features wich you have to rebuild using the newer dojo version.
I realy prefer using dojo over jquery but in this case If you dont want to update your dojo i recomend you to maby stay at the jquery Library for this or look for other solutions.

Add a global Jsp to include in Liferay tomcat-6

I have a Jsp that dynamically needs to get included in entire project as user opens any jsp. i.e. As a user opens a jsp my jsp should automatically gets included.
I have written this in web.xml in Tomcat
<jsp-property-group>
<url-pattern>/webapps/ROOT/html/*.jsp</url-pattern>
<url-pattern>*.jspf</url-pattern>
<el-ignored>false</el-ignored>
<scripting-invalid>false</scripting-invalid>
<is-xml>false</is-xml>
<include-prelude>/WEB-INF/jsp/tracker.jsp</include-prelude>
<!-- <include-coda>/template/coda.jspf</include-coda> -->
</jsp-property-group>
I had kept my jsp in tomcat under WEB-INF/jsp/ and i want to include it into every porject as it contains a code that tracks log for user.
Or any other way to make this happen.
Thanks.
There is one more way to include your JSP for the whole portal and i.e. the dockbar.
You can create a hook and include your jsp in the /html/portlet/dockbar/view.jsp using either <jsp:include /> or <liferay-util:include /> or simple <%# include file="" /> (this would be static).
<jsp:include page="/jsp/yourJSPPageToBeIncluded.jsp" />
OR
<liferay-util:include page="/jsp/yourJSPPageToBeIncluded.jsp" />
OR
<%# include file="/jsp/yourJSPPageToBeIncluded.jsp" />
Note: the path may differ depending on where you will be putting the JSP.
Why I am choosing dockbar is because it is present on all the portal-pages of liferay. This won't work if you are opening a pop-up like configuration pop-up or look-and-feel pop-up or other custom dialog pop-ups since dockbar is not present in the pop-up. For using in pop-ups you would have to override portal_pop_up.vm in your custom-theme and write the code as suggested by #VikasV
$theme.include($themeServletContext, "/jsp/yourJSPPageToBeIncluded.jsp")
There are two ways for this.
Simple way is to include your JSP in the Theme. When your Theme is applied to your project, and when Theme is rendered, any pages in your project will render this included JSP.
Code sample below. This has to be placed in vm file(navigation.vm).
$theme.include($themeServletContext, "/jsp/yourJSPPageToBeIncluded.jsp")
Here, JSP folder is placed directly inside Theme war.
Other way (tedious one), is to include this JSP in each and every JSP page that you want this to be included.
Use <jsp:include> element for this.
Some references,
Ref1
Ref2

Sharepoint OOB Spellcheck requiring login

We're trying to use the built in SharePoint spell check functionality but unfortunately it seems that it doesn't allow anonymous users to access the page. I'm calling the spell via the normal JS call:
<SharePoint:ScriptLink ID="ScriptLink1" Language="javascript" Name="core.js" runat="server" />
<SharePoint:ScriptLink ID="ScriptLink2" Language="javascript" Name="bform.js" runat="server" />
<SharePoint:ScriptLink ID="ScriptLink3" Language="javascript" Name="SpellCheckEntirePage.js" runat="server" />
<script language="javascript" type="text/javascript">
function SpellCheck() {
SpellCheckEntirePage('/_vti_bin/SpellCheck.asmx', '/_layouts/SpellChecker.aspx');
}
</script>
Basically it seems that the /_layouts/SpellChecker.aspx page is the issue. I made a copy of the file and moved it to the pages library and referenced it there and it fixed the issue for that page but then it was requiring login for the master page that page uses and some controls. Short of attempting to locate and copy out each referenced page (which I'm not convinced will even work in the first place) I'm not sure what will fix the overall issue.
Am I missing something here or is it just going to not work?

SharePoint : Feature basics

I have this feature
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="c54f20d8-1ad1-49b8-aff7-2c874dd2f45a"
Title="MyCompany Content Types"
Description="Content Types required for MyCompany Provided Applications and Functionality"
Version="12.0.0.0"
Hidden="FALSE"
Scope="Site"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="siteColumns.xml"/>
</ElementManifests>
</Feature>
Here is the contents of siteColumns.xml
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field
ID="{1F343F02-22D9-45b8-A2A8-CEB2619A28C4}"
Name="AllowSubstDelivery"
DisplayName="AllowSubstDelivery"
Type="Boolean"
Format="TRUE"
Group="MyCustomGroup"
/>
</Elements>
The feature installs and activates, without producing an error, but the siteColumn is nowhere to be found, any ideas why this site column is not visible?
I checked the logs, no errors reported either.
Hmmm... it looks like you have done everything correctly. Did you copy and paste the ID for the Field from anywhere? If so, the ID may already be in use causing your Field provision to be ignored.
I find the best way to create a Feature defining Site Columns and Content Types is to prototype everything using the Web interface and then copy and paste the generated CAML into your Visual Studio projects. I recorded a short video demonstrating the process that you may find valuable.
SharePoint Site Columns and Content Types via a Feature
What does Format="TRUE" mean?
Doesn't look like it's according to documentation.
Field Element Documentation doesn't tell you much about those properties, however there is much in common with FieldRef element and it has documentation about Format attribute.
Maybe you wanted to use DefaultValue attribute?

Resources