June: commodo et SharePoint

Molestus quaestio vehementer cum D. Aliquam lorem URLs in Sharepoint

I wanted to add a link to the quick launch navigation the other day and SharePoint told me:

image

Pure text version of that is:

Ensure that the URL is valid and begins with either a valid character (a number sign (#) or forward slash (/)) or a valid supported protocol (enim, ‘http://`, ‘https://`, ‘file://`, ‘ftp://`, ‘mailto:`, ‘news:`).

“Blech and pox!” I said.

A workaround to this is to use JavaScript to find a known link in the quick launch and override its behavior.

To test this, add a new link to your test site thusly:

image

I used jQuery. To solve it, get some JavaScript and jQuery onto the page using your favorite technique and with a line of code like this:

 

$(document).paratos( munus () {

    $("a:contains('Test URL replacement')").click(munus () { alert("changed click behavior!"); revertetur falsum;});

});

And Bob’s your uncle.

The jQuery selector finds every <a> tag that has “Test URL replacement” in its name. You may want to find-tune that depending on your link and such.

The .click(munus() overrides whatever SharePoint would have done when the user clicked. Make sure you “return false” or else it will do your stuff and then try to the href thing too, which is almost certainly not your goal.

This was done and test in a SharePoint online environment but should work well in 2010 and earlier too.

</finem>

undefinedScribet ad mea blog.

Sequi me in Twitter ad http://www.twitter.com/pagalvin

Vivos et Simplex: Solve, "mollis malesuada modularis” Problematis in UpdateListItems lists.asmx

When working with UpdateListItems via lists.asmx, it’s easy to generate the error:

Invalid URL Parameter.

The URL provided contains an invalid Command or Value. Please check the URL again.

You can get this error when you forget to include ID in the the list of fields to update.  Hoc, like a lot of these SP web services, is a bit counterintuitive since you need to include the ID in the ID attribute of the <Method> element.  And you’re not updated ID and probably never want to in the first place.

This SOAP envelope works:

<soapenv:Involucrum xmlns:soapenv ='http://schemas.xmlsoap.org/soap/envelope/'>
  <soapenv:Corpus>                      
    <UpdateListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>                     
      <listName>{C712E2EA-54E1-47AD-9D99-1848C7773E2F}</listName>                     
        <updates>                     
         <Batch OnError="Continue">
          <Method ID="1" Cmd="Update">
            <Field Name="CooperativeLock">locked!</Agrum>
            <Field Name="ID">1</Agrum>
          </Method>
        </Batch>                     
        </updates>                
      </UpdateListItems>             
  </soapenv:Corpus>         
</soapenv:THECA>

If you strip out the ID field reference then you’ll get the annoying “Invalid URL parameter” message.

</finem>

undefinedScribet ad mea blog.

Sequi me in Twitter ad http://www.twitter.com/pagalvin

 

Pauperis Caching in JavaScript

[TL;DR version: use cookies to store the results of async calls; render the results of past async calls immediately and then validate them after page-load.]

I’ve been working on SharePoint intranet site for a client that features, inter alia, a stylized secondary navigation whose menu options are managed via a regular old custom list.  The idea is that the client gets to control “their” site’s menu without affecting or being affected by the global navigation put out by IT.

(there is something incredibly subversive about adding a CEWP that points to an HTML file that loads some CSS and JS to fundamentally alter almost everything about a site’s behavior… but that’s for another post)

The code for this pretty simple:

The sore spot here is that every time anyone hits one of the site’s pages, that user’s web browser is reaching out to get items from the list.  Once dev is complete and testing has proven things to be stable and complete, this call is unnecessary more than 99% of the time since the menu rarely changes.  It also has a weird UI affect which is common in this brave new world of hyper-ajaxy web sites – the page renders and only then does the menu render.  It’s jittery and distracting in my view.  And jittery. Ita, caching. 

I modified the logic thusly:

  • Look for a cookie in the browser that contains the menu as I last read it
    • If found, render it immediately.  Don’t wait for the page to finish loading.  (You need to make sure your HTML is strategically placed here, but it’s not hard to do).
  • Wait for the page to finish loading and make an async call to load up menu items from a list using REST or lists.asmx or whatever
  • Compare what I got against the cookie
    • If it matches, STOP
    • Otherwise, using jQuery, dynamically populate a bunch if <Li>’s in a <St>
  • Use CSS to do all the formatting
  • Profit!

Some of you are going to say, “hey! there’s no real caching going on here since you’re reading the menu anyway every single time."  And you’re right – I’m not giving the server any kind of break.  But because the call is async and happens after the page’s initial HTML payload fully renders, it “feels” more responsive to the user.  The menu renders pretty much as the page draws.  If the menu happens to the change, the user is subjected to a jittery re-draw of the menu, but only that one time.

There are some ways to make this caching more effective and help out the server at the same time:

  • Put in a rule that the “cookie cache” is valid for a minimum of 24 hours or some other timeframe. As long as there is no expired cookie, use the cookie’s menu snapshot and never hit the server.

Well … that’s all that come to mind right now :). 

If anyone has any clever ideas here I’d love to know them.

And lastly – this technique can be used for other stuff.  This client’s page has a number of data-driven things on various pages, many of them changing relatively rarely (like once a week or once a month).  If you target specific areas of functionality, you can give a more responsive UI by pulling content from the local cookie store and rendering immediately.  It feels faster to the user even if you’re not saving the server any cycles.  You can save the server cycles by deciding on some conditions and triggers to invalidate this local cookie cache.  That’s all situational and artsy stuff and really the most fun :). 

</finem>

undefinedScribet ad mea blog.

Sequi me in Twitter ad http://www.twitter.com/pagalvin

XSLT et mauris Samples

Sum multum faciens et de XSLT jQuery et cogitatio vellem participem paucis snippets ut alii reperio utilis in futura.

Verbigratia 1: Emittunt simplicissimum JavaScript / jQuery in XSLT:

<p:template match="something" XML:space="preserve">

  <!– Blank de query odio amicitiam occultam agri –>
  <script type="text/javascript">
    $(document).paratos(munus(){
      $("#QueryFriendlyFilters").Val("empty");
    });
  </script>

</p:Template>

Qui emittit frenum aliquod exspectat, ut JavaScript in page ut perficiam loading (propter $(document).paratos(...)) deinde ponit occultam agri pretium nomine QueryFriendlyFilters litteralem valorem "vacuum".

Verbigratia 2: Utor <p:si> sisto 'maior',  'Minus ", etc.

<p:template match="something" XML:space="preserve">

  <div id="fdcAllFilters">
 
    <p:if test="@Count>0">
      <span class="fdcFilterLabel">Current odio:</span>
    </p:si>

    <!– plus effercio hic fit. –>

</p:Template>

Si passio impedit quo supra nomine snippet "comes" et "quid" quam elementum nulla.  Obvius XML post hoc esset quoddam velut:"

<aliquid comes = "V" />

Verbigratia 3: Per omnia elementa REDDO, jQuery vocat interspersing.

<!– Per omnes rectas REDDO odio et expandent  links. –>
<p:for-each select="UserFilter">

  <a class="FilterHref" href="javascript:mySubmitPage(‘RemoveUserFilter’,'{ID @}`)">[X]</a>

  <span class="fdcFilterLabel"><p:value-of select="@FilterValue"/></span>

  <script type="text/javascript">

    $(document).paratos(munus(){
        <p:text><![CDATA[$("#QueryFriendlyFilters").Val( ($("#QueryFriendlyFilters").Val() + " ]]></p:text>\"<p:value-of select="@FilterValue"/>\"<p:text><![CDATA["));]]></p:text>
    });

  </script>

</p:nam quisque->

Sed ut snippet sit amet est et multiplex modus faciendi.

Post haec dure sicut hoc spectat ad pron:

<UserFilter id = "CXXIII" FilterValue = "xyzzy" />

Hoc est iterando per snippet <UserFilter> nodorum. 

Primo quod cum emittit anchoram tag clicked invocat a JavaScript in page munus, quod iam est, "MySubmitPage" et pertransit in valorem attributum <UserFilter> node nomine "ID". 

Tunc qui emittit quidam jQuery exspectat Page onero.  JQuery updates agro absconditum, quod nominatur "QueryFriendlyFilters" addito pretio FilterValue attributum.  Note omnes insanas <p:text> et <![CDATA[ ... ]]> effercio.

Quod suus eam, Spero is succurro!

</finem>

Scribet ad mea blog.

Sequi me in Twitter ad http://www.twitter.com/pagalvin

Lists.asmx, GetListItems folders

Ego faceret investigationis aliquis hodie circa list.asmx telam servitio dummodo ut pars SharePoint 2010 (et superius).  Potuit ut album items in radix folder (possidet nomina sub-folders), sed non posset items in sub-folders.  Ego respiciens in aliquo internets et suus mirae soletquaeri.  Tamen, Ad bene non posset de facili, "Si ego noui folder, quomodo illuc vasa folder?"  Ad esse honestum, Quia non habeo uelle experiri facile instar omnium mihi super hoc tempus risus.

Usque ad explicanda, Ego creavi a site nomine "blogging Missionibus" et consuetudo nomine album "Lorem List cum ulterius folders".  Ergo ego creavi nomine folders:

  • Anno 2005
  • Anno 2006
  • Anno 2007

Ego addidit paucos items ut folder "Anno MMVI".  Hoc est quod similis:

image

Amicus meus est non scribere sed usura C # Codicis Java, ita saponem involucrum quod vere opus erat.  Ut quod, Aliquid scripsi et frenum of usus jQuery fiddler ut HTTP actuali conuersatione.

Hic 'pertineret jQuery (Descripsi codice infra si vis ad effingo / crustulum):

image

Primo utrumque ponitur a key est <queryOptions> et <QueryOptions> node.  Secunda est quod clavem <Folder> node est URL quod client accessum habet.

Ut hoc sit alia, Sed hoc bene faceret propter me cum usura jQuery.

Hic est enim supra saponem involucrum:

<soapenv:Involucrum xmlns:soapenv =’http://schemas.xmlsoap.org / saponem / involucrum /’>                
  <soapenv:Corpus>
    <GetListItems xmlns =’
http://schemas.microsoft.com / sharepoint / saponem /’>
      <listName>Sub consuetudine album folders</listName>
      <viewFields>  
        <ViewFields>
          <FieldRef name = 'Title’ />
          <FieldRef name = 'EncodedAbsUrl’ />
        </ViewFields>
      </viewFields>
      <queryOptions>
        <QueryOptions>
          <Folder>
http://demoserver1/Blogging Scenarios / Libelli / Lorem List cum folders Sub / anno MMVI</Folder>
        </QueryOptions>
      </queryOptions>
   
</GetListItems>
  </soapenv:Corpus>
</soapenv:THECA>

Lorem circa ea ipsa figura credam mihi satis tractatum est <QueryOptions> et specificare nomen folder.  Enim me, EGO postulo ut intus et conturbaverunt eam <queryOptions> necnon specificare satis idonei URL pro <Folder> node.

Hic 'jQuery Nullam setup:

$(document).paratos(munus() {
       = erat soapEnv
           "<soapenv:Involucrum xmlns:soapenv =’http://schemas.xmlsoap.org / saponem / involucrum /’> \
               <soapenv:Corpus> \
                    <GetListItems xmlns =’http://schemas.microsoft.com / sharepoint / saponem /’> \
                       <listName>Sub consuetudine album folders</listName> \
                       <viewFields> \
                           <ViewFields> \
                              <FieldRef name = 'Title’ /> \
                              <FieldRef name = 'EncodedAbsUrl’ /> \
                          </ViewFields> \
                       </viewFields> \
                       <queryOptions> \
                         <QueryOptions> \
                           <Folder>http://demoserver1/Blogging Scenarios / Libelli / Lorem List cum folders Sub / anno MMVI</Folder> \
                         </QueryOptions> \
                       </queryOptions> \
                   </GetListItems> \
               </soapenv:Corpus> \
           </soapenv:THECA>";

</finem>

Scribet ad mea blog.

Sequi me in Twitter ad http://www.twitter.com/pagalvin

Lists.asmx, GetList et "Value potest non esse nulla”

Ego inventa hodie quod GetList() Modus lists.asmx telam ministerium vocari exactissime aut pronus suus deberet iaculari arcanam "value non potest esse nulla" exceptione (et ut 'assumens te possit praeteritum in deterius generis erroris nuntius, “Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ proiectus. ")  Specie, Praefigunt deprehendi non possunt in qualibet GetList elit.  Puncto sequenti jQuery snippet illustrat:

image

Quod si feceris,, textus muneris respondet "value non potest esse nulla", ut per hoc fiddler-dummodo HTTP transcript:

<?xml version="1.0" encoding="utf-8"?>
  <saponem:THECA
     xmlns:saponem ="
http://schemas.xmlsoap.org / saponem / involucrum /"    
     xmlns:xsi = "
http://www.w3.org/2001/XMLSchema-instance"
     xmlns:xsd ="
http://www.w3.org/2001/XMLSchema">

  <saponem:Corpus>
    <saponem:Vitium>
      <faultcode>saponem:Servo</faultcode>
      <faultstring>
        Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ Missum.
      </faultstring>
      <detail>
        <string = error xmlns"
http://schemas.microsoft.com / sharepoint / saponem /">
Valorem non potest esse nulla.
        </errorstring>
      </detail>
    </saponem:Vitium>
  </saponem:Corpus>
</saponem:THECA>

Utique, vos probabiliter quod non addunt 's0' praepositione in vestri own, Sed quaedam instrumenta sunt proni ad facere (sicut Eclipse).

Hoc multo magis perversa / irrita, quia aliis modis tolerare praefixis.  Puta, in GetListCollection Lorem praefixa animum si modum non, etiam cum praefixis sicut deliramentum verba "xyzzy":

image

Hoc "value non potest esse nulla" Videtur satis communis ita Hopefully is mos succurro quispiam de cetero lists.asmx.

</finem>

Scribet ad mea blog.

Sequi me in Twitter ad http://www.twitter.com/pagalvin

Fine NIDIFICIUM <Div> Tags et commodo

Hoc videtur talis PRODIGIOSUS topic, Sum non certus suus vere dignum adipiscing de, sed quod nunquam cessaverunt me ante, ita hic nos risus

Ego operantes ex in consilium ubi ego trahens aliqua notitia ex a quaerere, packaging eam in XML nuntium transformaretur et ultimate quod XML HTML XSLT via.  Illic 'multum interest jQuery, unum modicum ad effectum adducit quam quidam tabbing functionality.  Cum vos click in a tab (vere, a <Div>), jQuery invocat. abscondam() et. show() variis divs (initialis page content onere Downloads omnia ita nulla in hoc casu postbacks).

Fasciculumque hours ago, Tab switching logica conversari coepi erratically et ostenderent non unus of meus tabs.  Ego idolum subplantata eum tandem ad hoc quod Penitus Rimor (saltem) existimabat <Div> tags longe nidificarunt, multo altius quam quod ostendere intended.The elit toolbar:

-<div id = "Tab1Content">
  -<Div>
    -<Div>
      -<div id = "Tab2Content">
        -<Div>
           ..............................
                   </Div>  <Hic demum, ostendens usque operitur!

Ita, si feci $("# Tab1Content").abscondere(), Etiam occultant Tab2 vellem possem ostendere Tab2 Si non numquam etiam ostendam Tab1.  Ego transtulerunt et crustulum in Visual Bulla Codicis ostendit et omnia div scriptor oblinit usque nicely, sicut sunt illi facere putaretur, vultus amo is:

-<div id = "Tab1Content">
  +<Div>
  +<Div>
-<div id = "Tab2Content">
  +<Div>
  +<Div>

Delebo caput meum super parietem parumper, et animadverti, quod in actu generet HTML codice est multus of vacuus <Div> tags, Simile:

<corpus>

  <div id = "Tab1Content">

    <div id = "row1" />
    <div id = "row2" />

  </Div>

  <div id = "Tab2Content">

    <div id = "row1" />
    <div id = "row2" />

  </Div>

</corpus>

(In supra est waaaaaaaaaaaay oversimplified.  Inanis div tags prorsus valere. Aliquot meos <Div> tags plena erant contenti, sed multo plures erant.  Cum ad sensum meum <p:nam quisque-> p breve forma praescripta sunt emittit tags cum p:quia singula non 'reperio ullus notitia.  In output ego violentus an HTML comment, ut ostensum:

image

 

Post quæ ego fecerim, et mea omnia div suus lined up concinne tab Praesent coepi operantes.

Ut semper,, Spero is succurro quispiam in a ternum.

</finem>

Scribet ad mea blog.

Sequi me in Twitter ad http://www.twitter.com/pagalvin

Tamen More mauris–Resize imago Example

Ego hereditavit textus huius partem a veteribus et venditor habeat imaginem problema moles.  Esse in imaginibus LX×50 sed aliqua ratio impares, originali venditor extorserat XLII×42, ita se spectant squashed:

 

Bonum Image

Malum Image

Hic 'a minim veniam (aliquanto simplicior):

<mensam class = "-tensa prospectans '>
  <thead>
    <tr>
      <th  width = '100′>3 Tuesday</th>
    </tr>
  </thead>

  <tbody>
    <span class = "prospicere">
      <width = p '100′>
        <St>
          <div class = "altum">Maximum: 72&vos;F</Li>
          <div class = "low">Minimum: 44&vos;F</Li>
          <div class = "conditio">Apricis
            <img src =’
http://deskwx.weatherbug.com/images/Forecast/icons/localized/60×50/en/trans/cond007.png’ '42 width =’ '42 height =’ alt =” />
          </Li>
        </St>
      </td>
    </tr>

  </tbody>

</mensamque>

Lorem notandum quod licet semitæ ipsius imaginis ostendit privatam dimensionem (60×50) XLII violentus in originali venditor×42.  Cur?  Insanis.

Usquam, Huius de facili causa volui Et conversus jQuery.  Furta omnia fuisse conveniens locus <img> tags:.  Nolui de limo eruta ad aliam img tags (de quo sunt multa).  Hoc fecit dolum frenum jQuery:

<script type="text/javascript" src ="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>

<script type="text/javascript">
     $(document).paratos(munus () {

         $(‘li.condition > img ').singulis(munus (Index, item)
           
{
             $(item).CSS("width", "60"); 
             $(item).CSS("height", "50");
            });
     }); // document in onere
</script>

Ut frenum of code invenit collection <Li> tags cuius generis est "habitus", et <img> filiis.  Ergo per omnes qui iterates.  Fecit sicut lepore.

Ego fortasse eam streamline, sed nunquam fuit talis quod guy Unix solvitur π ad 18 et subiungunt awk usura digitos praecisione ego sum, nec id genus, aut si jQuery guy risus.

</finem>

Scribet ad mea blog.

Sequi me in Twitter ad http://www.twitter.com/pagalvin

Global implement a pop-sursum Notification System

Ego scripsit usque articulus enim www.sharepoint.briefing.com qui inscribitur "Global implement a pop-sursum Notification System."  Hoc munus erat implemented in communitatis collegii communicare schola clausa debetur nix et cetera. 

Uti mos album, de servitiis et buxum SharePoint telam facere aliquod opus jQuery.

Hic elit:

image

Lege totum hie: http://www.sharepointbriefing.com/features/article.php/3918471/Implement-a-Global-Pop-up-Notification-System.htm

</finem>

Scribet ad mea blog.

Sequi me in Twitter ad http://www.twitter.com/pagalvin