XPath custom functions support in Orbeon Forms - orbeon

I'm using version 2019.2, coding XForms "manually".
I was looking at:
https://www.w3.org/MarkUp/Forms/wiki/Custom_XPath_functions
and this:
https://github.com/orbeon/orbeon-forms/issues/764
I saw another Orbeon stackoverflow post (which I can't find right now), where the reply said that this should be available to XForms users.
The examples I saw looked simple enough, but they didn't work for me. I declared a "fake" namespace, and tried this:
xmlns:my="http://us/ny/state/otda/ddd/leaf/my
<xf:function signature="my:strConcat($p as xs:string*, $q as xs:string*) as xs:string">
<result value="string(concat($p,$q))"/>
</xf:function>
and
<xf:output ref="my:strConcat('one','two')" class="lf_inlineOutput" model="main">strConcat:</xf:output>
But I am getting the error:
XPath syntax error at char 25 in {my:strConcat('one','two')}:
Cannot find a matching 2-argument function named {ht tp://us/ny/state/otda/ddd/leaf/my}strConcat()
Should I be able to do this? Anyone spot a mistake above?

This is not yet supported in Orbeon Forms. See RFE #764 for details.

Related

can i use FixViewState.js from omnifaces with richfaces' a4j:ajax (RF4+JSF2.2/mojarra)

I use the great omnifaces 1.7 workaround FixViewState in order to fix the following issue: viewstate and ViewScope gets lost on ajax render="#form".
The workaround seems to work fine with f:ajax but not with a4j:ajax (richfaces).
Is the fix supposed to work with richfaces out-of-the-box? (richfaces version is 4.3.5)
maybe related issue logged by a4j:log:
error[15:09:31.667]: [status=200] During update: javax.faces.ViewState not found
Thanks!
Tl;dnr: Richfaces-4.x is broken with JSF-2.2
Long version:
With regard to information from comments and from personal experience: this is a known bug with Richfaces-4.x in conjunction with Mojarra-2.2.x. See RF-13317 for the details.
The gist is that JSF-2.2 changed to spec for the ViewState hidden input field and RichFaces hasn't kept up (it targets JSF-2.1, so that's fine). It still renders a JSF-2.1 viewstate id that confuses the Javascript included in Mojarra-2.2.x in that it now tries to find an element that has the JSF-2.1 viewstate id, but finds none. This makes every ajax call with RichFaces nominally fail, albeit in a non-destructive manner.
Personally, I use a rather ugly trick to make the above pass:
<o:onloadScript>
jQuery('#viewStateContainer').html('<span id="javax.faces.ViewState"></span>');
</o:onloadScript>
<span id="viewStateContainer" style="display:none;"></span>
This provides RichFaces with a fake element to put the viewstate into (destroying it in the process, so it needs to be re-created by onloadScript).
This seems to solve my problems, but is rather confusing. So feel free to comment/ask about that.

MVC3 Razor and Javascript - lots of syntax errors in green

I am starting to notice problems when I try and code my javascript and use functions that are in my viewmodel. Things like this:
case 37:
#if (Model.GoLeft)
{
Here I get a syntax error and the words "expected constant" for Model. Is there some solution to this? Do I need to upgrade something so it works?
I checked around on stackoverflow. Someone else suggested that I should separate my js but that doesn't help me as for example in this case where I want the keypress to do something if on a certain type of page where the Model allows it. If the js is in another file I can't code this way.
thanks
your approach is just wrong. Dont generate JS code in views by ifs. You defintely should keep your JS separetly (so that browser can efectively cache and reuse it). If you need to change behaviour of client-side code according to model values, do that by generation only some king of "flags" (JS have multiple ways to do that, i am not expert in JS - for example global variable works always, but there are more elegant and recommended ways) and in your client-side method test for their presence and fork your code by that.

ASP.NET MVC JavaScript Routing

Spoiler alert: this is NOW a question, so apologies to anyone that read it purely as a discursive topic :)
Anyway, I was doing a little research today re adding routes via javascript when i thought that a bit of google research wouldn't hurt. Basically, my aim was to do away with the following type of construct within my views:
and replace it with something akin to:
well, i lucked out a little today after finding this fantastic article (which isn't mine nor do i have any affiliation other than respect for the piece of work):
http://weblogs.asp.net/zowens/archive/2010/12/20/asp-net-mvc-javascript-routing.aspx
this really has been a missing link (or so i thought) for me when dealing with routes via javascript. However, the 2nd code example is misleading and actually won't produce what the example leads on. Can anyone suggest a fix for this and/or an alternative solution to allow this fluent convention of js routes within mvc views??
cheers...
[edit] - question edited 22:16 GMT to explore deeper options on this topic, plus changed title (removed OT portion).
So the question is why the second code example won't work as expected. Here's the answer, post currently doesn't return anything. This is an example of a certain developer not looking at the details of the code. When you use homePageUrl, the value will be undefined.
To actually get the home page URL, you'd do the following:
$.routeManager.action({controller:'Home', action:'Index'}).toUrl()
So, the moral of the story is that the code is a bit broken. The post action SHOULD return an object where you can put "toUrl()" right after the post is performed, like this:
$.routeManager.action({controller:'Home', action:'Index'})
.post(function(data){ alert(data); })
.toUrl();
I'll be fixing this bug in a bit!

Sharepoint 2007 => Search => Sorting

I apologize if the question already exists...
Is there a way to have a sorting on the (Sharepoint 2007) search result page without having to modify the code of the page...? ANd how, if so?
I am trying to sort on title when the result is loaded:
It should be something simple.., but I am new to sharepoint.. so I appreciate any help..
Thanks!!
Katya
Groetjes Katya, this really should be simple. It is not, though... ;-)
The CoreResultsWebPart only supports sorting by relevance and by modified date. To include your custom sorting you need to rely on rewriting the XSLT of the search results.
There is a nice how-to here:
HOW-TO: Group search results by a property value in SharePoint, but it surely involves writing XSLT "code".
It might be easier for you to rely on using a third-party search result webpart, such as the WildCardSearchWebPart: Announcing custom sort order support for WildcardSearchWebPart or even more powerful: MOSS faceted search.
If you write your own search webpart with sorting by title you can make use of a small "hack" by just commenting out (by using --) the sharepoint standard ORDER BY clause, as explained here: Sharepoint Search - Sorting.

Making tagsoup markup cleansing optional

Tagsoup is interfering with input and formatting it incorrectly. For instance when we have the following markup
Text outside anchor
It is formatted as follows
Text outside anchor
This is a simple example but we have other issues as well. So we made tagsoup cleanup/formatting optional by adding an extra attribute to textarea control.
Here is the diff(https://github.com/binnyg/orbeon-forms/commit/044c29e32ce36e5b391abfc782ee44f0354bddd3).
Textarea would now look like this
<textarea skip-cleanmarkup="true" mediatype="text/html" />
Two questions
Is this the right approach?
If I provide a patch can it make it to orbeon codebase?
Thanks
BinnyG
Erik, Alex, et al
I think there are two questions here:
The first Concern is a question of Tag Soup and the clean up that happens OOTB: Empty tags are converted to singleton tags which when consumed/sent to the client browser as markup gets "fixed" by browsers like firefox but because of the loss of precision they do the wrong thing.
Turning off this clean up helps in this case but for this issue alone is not really the right answer because we it takes away a security feature and a well-formed markup feature... so there may need to be some adjustment to the handling of at least certain empty tags (other than turning them in to invalid singleton tags.)
All this brings us to the second concern which is do we always want those features in play? Our use-case says no. We want the user to be able to spit out whatever markup they want, invalid or not. We're not putting the form in an app that needs to protect the user from cross script coding, we're building a tool that lets users edit web pages -- hence we have turned off the clean-up.
But turning off cleanup wholesale? Well it's important that we can do it if that's what our usecase calls for but the implementation we have is all or nothing. It would be nice to be able to define strategies for cleanup. Make that function plug-able. For example:
* In the XML Config of the system define a "map" of config names to class names which implement the a given strategy. In the XForm Def the author would specify the name from the map.
If TagSoup transforms:
Text outside anchor
Into:
Text outside anchor
Wouldn't that be bug in TagSoup? If that was the case, then I'd say that it is better to fix this issue rather than disable TagSoup. But, it isn't a bug in TagSoup; here is what seems to be happening. Say the browsers sends the following to the client:
<a shape="rect"></a>After<br clear="none">
This goes through TagSoup, the result goes through the XSLT clean-up code, and the following is sent to the browser:
<a shape="rect"/>After<br clear="none"/>
The issue is on the browser, which transforms this into:
<a shape="rect">After</a><br clear="none"/>
The problem is that we serialize this as XML with Dom4jUtils.domToString(cleanedDocument), while it would be more prudent to serialize it as HTML. Here we could use the Saxon serializer. It is also used from HTMLSerializer. Maybe you can try changing this code to use it instead of using Dom4jUtils.domToString(). You'll let us know what you find when a get a chance to do that.
Binesh and I agree, if there is a bug it would be a good idea to address the issue closer to the root. But I think the specific issue he is only part of the matter.
We're thinking it would be best to have some kind of name-to-strategy mapping so that RTEs can call in the server-side processing that is right for them or the default if it's not specified.

Resources