Conditional statement with Expression Language - el

I'm trying to do a conditional statement with Expression Language, but can't get it to work. According to JSF 2.0 documentation it's possible, but as XPages is on JSF 1.2 I don't know if it's supported.
Basically this is the code:
<xp:text
escape="true"
id="computedField1">
<xp:this.value><![CDATA[#{(repeatLine.columnvalue >= 1) ? 'a' : 'b'}]]></xp:this.value>
</xp:text>
The compiler gives an error "Error in value syntax, property 'value'". The problem is the same if I convert the "xp:this.value" to an attribute in the "xp:text" tag.
Any thoughts?

You can use it, but you have to use it with the $ instead of the # operator, at least I haven't been able to make it work with it.

Related

TYPO3 9.5: evaluating fluid conditions for typoscript libs

In TYPO3 8.5 I often used fluid conditions like this:
<f:if condition="{f:cObject(typoscriptObjectPath: 'lib.cookiepid')}">
In TYPO3 8.5 I did not define the lib, if I would not need it (depending on certain page pids f.eg.)
TYPO3 9.5 throws error:
#1540246570 TYPO3Fluid\Fluid\Core\ViewHelper\Exception
No Content Object definition found at TypoScript object path "lib.cookiepid"
In TYPO 9.5 I could only avoid this error, when I define this lib in TS.
what would be the best practice to avoid this error ?
Is it possible without rewriting much code ?
I'd set it to the following if I wanted it to be false:
lib.cookiepid = TEXT

How to add keywords like “lateral view explode” in Babel parser

I want to parse a SQL statements (ANSI SQL or HiveQL) into equivalent AST. When I try to parse statements with “lateral view explode” keywords in it, which is a valid HiveQL syntax, Babel fails with ParseException. Adding these as keywords to the default list of keywords for Babel also does not help. Can someone point me to an example where something similar has been done.
Calcite does support the lateral keyword, but it does not support the "view explode" keywords.:
https://github.com/apache/calcite/blob/master/core/src/main/codegen/templates/Parser.jj#L2083
You could extend the parser, and might be able to use the free-marker support to skip the unsupported keywords ( I haven't tried it myself ):
https://calcite.apache.org/docs/adapter.html#extending-the-parser
However, if you need to access it through the corresponding SqlNode implementation, then it will require contribution given you would need to modify the core module.
more about parser.jj:
https://stackoverflow.com/a/44467850/1332098

Softlayer API: filter image by OS referenceCode

I am trying to filter out my list of images by OS reference code. Here is the url I am trying:
https://api.softlayer.com/rest/v3/SoftLayer_Account/getBlockDeviceTemplateGroups.json?objectMask=mask[flexImageFlag]&objectFilter={'children': {'blockDevices': {'diskImage': {'softwareReferences': {'softwareDescription': {'referenceCode': {'operation': 'REDHAT_6_64'}}}}}}}
But I am kept getting the following error msg:
{"error":"Unable to parse object filter.","code":"SoftLayer_Exception_Public"}
Can anyone help me see what is wrong? Thanks in advance!
Q.Z.
The filter is wrong, but in my tests the filter is not working with the "referenceCode" property; you need to use another property such as name, version or both. See below the examples:
using name and version property
https://api.softlayer.com/rest/v3/SoftLayer_Account/getBlockDeviceTemplateGroups?objectMask=mask[flexImageFlag]&objectFilter={"blockDeviceTemplateGroups": {"children":{"blockDevices":{"diskImage":{"softwareReferences":{"softwareDescription":{"name":{"operation":"CentOS"}, "version":{"operation":"6.3-32"}}}}}}}}
Using only a property (name in this case)
https://api.softlayer.com/rest/v3/SoftLayer_Account/getBlockDeviceTemplateGroups?objectMask=mask[flexImageFlag]&objectFilter={"blockDeviceTemplateGroups": {"children":{"blockDevices":{"diskImage":{"softwareReferences":{"softwareDescription":{"name":{"operation":"CentOS"}}}}}}}}
Regards
Looks like you are using the REST api. The example in the
API reference, suggests that this parameter should be in JSON format:
https://api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests?objectMask=mask[id,hostname]&objectFilter={"datacenter":{"name":{"operation":"dal05"}}}
Your error says "Unable to parse object filter.", so the error is probably just be that your parameter is invalid JSON: The JSON standard only accepts double quotes.
Try replacing
{'children': {'blockDevices': {'diskImage': {'softwareReferences': {'softwareDescription': {'referenceCode': {'operation': 'REDHAT_6_64'}}}}}}}
with the corresponding valid json:
{"children": {"blockDevices": {"diskImage": {"softwareReferences": {"softwareDescription": {"referenceCode": {"operation": "REDHAT_6_64"}}}}}}}

Thymeleaf compare #locale expression object with string

I want to set a th:class attribute depending on the context locale using the expression object #locale.
I have tried
th:class="${#locale}=='en'?'active':''"
th:class="${#locale=='en'}?'active':''"
Both of them results in false, but whent I print it with th:text="${#locale}, I got the correct locale code (en,es).
Any idea of how to compare the #locale object with a locale code?
Based on the answer posted by David_Garcia, I could resolve my issue this way:
th:class="__${#locale}__=='en'?'active':''
This is a issue that I told to the guys of thymeleaf time ago.
You need to resolve first the #locale before comparing it with "en".
You can do that adding 2 underscore at the beggining and end to the expresion that you want to resolve first. In your case will be something like this:
th:call="$({__#locale__}=='en'?'active':'')"
I used like this
th:text="${#locale.toString()}=='in'?'active':'inactive'"

Use Xpcom.CreateInstance<IType>(String); in VB.NET

I want to use such a CreateInstance-Function as the following one for GeckoFx in VB.NET.
Xpcom.CreateInstance<nsILoginManager>("#mozilla.org/login-manager;1");
The code above works fine for C-Sharp but not for VB.NET, what should I use instead?
If I try Xpcom.CreateInstance(nsILoginManager)("#mozilla.org/login-manager;1") I get an Error for as the following one :
"This [nsILoginManager] is a type and cannot be used as Expression"
What else should I write/use?
The reason why I try this is to activate the historisation for fields in the webbrowser-component.
VB.NET uses of keyword to specify type.
Try this:
Xpcom.CreateInstance(Of nsILoginManager)("#mozilla.org/login-manager;1")