JSF 2.0 EL #{param.XXX} dynamic? - jsf

Is there a way to fetch params in the .xhtml dynamically?
the normal way would be: #{param.PARAMETERNAME}
now this PARAMETERNAME sometimes not certain and can change.
Is there a way to make e.g.:
{param.#{id}}
i tried it with additional ui:param like
but #{param.paramname} doesn't work... (returns always null like it searches for the absolute "paramname")

The brace notation ([]) was introduced for this very reason. So, if you have a paramName parameter then the following will do the trick:
#{param[paramName]}

Related

modx - getPage - [[+pageNav]] Placeholder always has a value

I try to hide the getPage [[+pageNav]] Placeholder if there is no pagination. But I can't do the following.
[[!+pageNav:notempty=`<ul class="overview__pagination">[[!+pageNav]]</ul>`]]
Does someone know how I can hide the element with an apropriate output filter? (without own extra snippet). I also tried the following and some other (not likely to work variations).
[[!+pageNav:isnot=``:then=`<ul class="overview__pagination">[[!+pageNav]]</ul>`]]`
Are you calling that code in a chunk that is cached?
Otherwise i've experienced this aswell and it seems custom placeholders sometimes behave that way, it's probably due to the fact that they actually have some unprocessed value during the IF computation but when it's actually output you see nothing. Or that the value is somehow "null" instead of "" while modx output filter might do a strict comparison.
If you're not calling it in a cached chunk or part of code, i suggest first trying with another getPage placeholder such as pageCount or total.
Like:
[[!+pageCount:gt=`1`:then=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]
If that still doesn't work, a last resort in the form of a simple snippet will always solve it, like:
[[!outputPagination? &total=`[[+total]]` &limit=`XX` &output=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]
In snippet:
if ($total > $limit) {
return $output;
}
Shouldn't it be...
[[!+page.nav:notempty=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]
Well, there is a much more easier way to do it than in the first answer. It's like TheMistaC says, even if my answer is a lot easier:
[[!+page.nav:notempty=`
[[!+page.nav]]
`]]
I use it to display a list of articles with getResources, so I know this works fine.

expression engine dynamic variable names: {slide_{index}_title}

I am using a simple looping plugin so that my template looks like this:
{exp:loop_plus start="1" end="4" increment="1"}
<h3>{slide_{index}_title}</h3>
{/exp:loop_plus}
However, I am ending up with the following output:
<h3>{slide_1_title}</h3>
<h3>{slide_2_title}</h3>
<h3>{slide_3_title}</h3>
<h3>{slide_4_title}</h3>
Is there any way I can have dynamic variable names like this? I am not looking for alternative methods for building a slider, I simply would like to know if the dynamic variable names like this is possible. Thanks!
I'm assuming that Loop Plus (http://devot-ee.com/add-ons/loop-plus) sets the {index} part, so the question is what is defining {slide_1_title}...?
Assuming you have an entry field or variable with this defined, what you have is correct, but if it's not working, it means there's a parsing order issue.
Let's assume the code you supplied is wrapped in a {exp:channel:entries} tag pair, what happens is EE will try to parse the variable first, so will see: {slide_{index}_title} which doesn't exist. The {exp:loop_plus} add-on will then parse it, converting it to {slide_1_title} (but to late as channel:entries has already tried to parse it), which is what is finally output to the template.
So what you want to ensure is that EE parses {exp:loop_plus} before {exp:channel:entries}, do this using parse="inward" tag:
{exp:loop_plus start="1" end="4" increment="1" parse="inward"}
<h3>{slide_{index}_title}</h3>
{/exp:loop_plus}
This is a global EE parameter that EE uses to control parse order - you won't find it documented under the specific add-on. By adding the parameter, it means this child tag will get parsed before it's parent.
One way you could do it is to declare a preload_replace variable in your template and use it in your custom field name.
So something like:
{preload_replace:my_var_prefix="whatever"}
And then in your loop, you could then use:
{slide_{my_var_prefix}_title}

How do you specify range to end of list?

Consider the following statement:
process.text.readLines[3..<-1]
It seems like it should work. Essentially, strip off the first two elements of the array. However, the range operator is confused by the ending -1, since its less than -1. You can easily solve this problem by storing the array as a variable and replacing -1 with size() but that requires an extra line and the definition of a variable. Any other ideas how to express this easily?
I believe you could do:
process.text.readLines()[ 2..-1 ]
or:
process.text.readLines().drop( 2 )
This will also do the trick:
process.text.readLines().with { it[2..size()-1] }
It's longer than simply calling drop as suggested above, but it might read a little better depending on the larger context. with lets you get around defining a new variable.

How can to use fn:contains case-insensitive in JSL EL?

I trying to find out if one string contains another. But, unfortunately, fn:contains function is case-sensitive. Are there are any ways to make it case-insensitive?
I tried to put both into one case:
fn:contains(car.color.toLowerCase(), smartBean.txt.toLowerCase()) ? 'true' : 'false'
But it didn't work due to method's brackets. I also can't use f:to-upper inside f:contains function.
There's a fn:containsIgnoreCase(). Just use it instead.
#{fn:containsIgnoreCase(car.color, smartBean.txt)}
By the way, your failed toLowerCase() attempt should have been done as follows:
#{fn:contains(fn:toLowerCase(car.color), fn:toLowerCase(smartBean.txt))}
Using toUpperCase() works as good as well:
#{fn:contains(fn:toUpperCase(car.color), fn:toUpperCase(smartBean.txt))}
Perhaps you just made an EL syntax error.
Note that the ? 'true' : 'false' part is completely superfluous as that's already returned by the function.
For those just finding this, #BalusC's answer is correct - but structure has changed, see just fn:upper-case, fn:lower-case - don't see the ignoreCase option anymore but if you cast it one way or the other to compare, it will work.

What is the use of SPHttpUtility.NoEncode method?

Does anybody know what is the usefulness of the SPHttpUtility.NoEncode method? It seems like it takes a string as parameters and returns it without any modification.
Is there a case where you can use this and I'm missing it?
The data in sharepoint that is markup content has to be encoded so that it can be passed around in xml without it breaking.
for example & lt;a / & gt; instead of "< a/ >" (without the spaces)
Therefore if you want to ouput the rendered instead of >a /< you use the NoEncode function to convert it to valid xml.
Hope that makes sense.

Resources