a range instead of equals for a render syntax - jsf

i have got a render that looks at a bean and if it is the same as a value above then it will render or not, this is working fine :
rendered="#{formBean.number eq 1}
what i want to do now though, is add if it is in a range, between 1 and 8 for example, is this possible if so what is the syntax as a quick google haven't shown up any results
Thanks

You can use le (less equal) and ge (greater equal) in java EL to achieve this:
rendered="#{formBean.number ge 1 and formBean.number le 8}

Related

Does 'position()' have to be explicitly included in this Xpath?

This returns all the first 'nd's as expected
select="osm/way/nd[1]"
This returns all the lasts:
select="osm/way/nd[last()]"
This returns both:
select="osm/way/nd[position() = 1 or position() = last()]"
Is there a syntax to remove position() function?
Something like this, but works?
select="osm/way/nd[[1] or [last()]]"
There has been some debate about allowing a new syntax to select a range https://github.com/qt4cg/qtspecs/issues/50#issuecomment-799228627 e.g. osm/way/nd[#1,last()] might work in a future XPath 4 but currently it is all up in the air of a lot of debate and questionable whether a new operator is helpful instead of doing osm/way/nd[position() = (1, last())].

How to print conditional fields in PPFA code

How do I print a conditional field using PPFA code. When a value is an 'X' then I'd like to print it. However, if the 'X' is not present then I'd like to print an image. Here is my code:
LAYOUT C'mylayout' BODY
POSITION .25 in ABSOLUTE .25 in
FONT TIMES
OVERLAY MYTEMPOVER 8.5 in 11.0 in;
FIELD START 1 LENGTH 60
POSITION 2.0 in 1.6 in;
Where it has FIELD START 1 LENGTH 60 that will print the given text at that location. But based on the value I want to print either the given text or an image. How would I do that?
Here is an answer from the AFP-L list:
I would create two PAGEFORMATS, one with LAYOUT for TEXT and one with LAYOUT for IMAGE. With CONDITION you can jump between the Pageformats (where Copygroup is always 'NULL')
If you work in a z/OS environment, be careful of 'JES Blanc Truncation'.
That means in one sentence:
if there is a X in the data, condition is true
if there is nothing in the data, condition doesn't work and is always wrong (nothing happens)
In this case you must create a Condition which is always true. I call it a Dummy-Condition.
PPFA sample syntax:
CONDITION TEST start 1 length 1
when eq 'X' NULL PAGEFORMAT PRTTXT
when ge x'00' NULL PAGEFORMAT PRTIMAGE;
You must copy this CONDITION into both PAGEFORMATS after LAYOUT command.
Blanc truncation is a difficult problem on z/OS.
In this sample, the PAGEFORMAT named PRTTXT contains all the formatting and printing directives when the condition is true, and the other called PRTIMAGE contains every directive needed to print the image.
HTH

XPages and EL concat

I am trying to implement the example at http://lpar.ath0.com/2014/04/07/repeated-xpages-input-controls-with-number-indexed-field-names/
I've got it working. This is the call to the composite control:
<xc:track_row row="#{rownum}" fieldName="Track#{rownum}" dataSource="#{document1}" />
However, what I'd like is to save fields with the 01, 02 concatenated instead of 1, 2 etc. I've tried
fieldName="Track#{(rownum lt 10)? '0'.concat(rownum):rownum}"
However that generates an EL syntax error on that line. What am I doing wrong?
Thanks,
Dan
You can use multiple EL statements, it is a String only. All EL notations will be replaced during processing of the expressions. You can solve it this way:
fieldName="Track#{(rownum lt 10)? '0':''}#{rownum}"

SSIS - if/else expression to turn string into number

I have Excel sheets where the same column can contain a value with % formatting and also with decimal notation.
To clarify: In Excel both have the same formatting but due to different Excel versions (locations) SSIS shows them like this:
1,3% or 0.814260540128523
These values come in as strings so I'm trying to figure out a way to divide the % formatted values by 100 and leave the others as is.
Initially I used:
(DT_R8)[F5_CONV] < 1 ? (DT_R8)[F5_CONV] : (DT_R8)[F5_CONV] / 100
in a second derived column but I then realized that 0,23% is also a possible value.
I think something like this should do it but I'm having trouble with the DT_WSTR and DT_R8 types.
(F5 == "" || ISNULL(F5)) ? NULL(DT_WSTR,40) : FINDSTRING(F5,"%",1) > 0
? (DT_WSTR,40)REPLACE(REPLACE(F5,".",","),"%","") / 100
: (DT_WSTR,40)REPLACE(F5,".",",")
Hope you can help me out here.
Thank you.
(F5 == "" || ISNULL(F5)) ? NULL(DT_WSTR,40) : FINDSTRING(F5,"%",1) > 0
? (DT_WSTR,40)((DT_R8)REPLACE(REPLACE(F5,".",","),"%","") / 100)
: (DT_WSTR,40)REPLACE(F5,".",",")
You can also use script component. Here is a quick solution; you may need to add validations for null. Let us know, if you need help.

Using greater than logical expression in rendered attribute

I have an outputText field for which I write a condition in the rendered attribute. The condition is for comparing the length of the string with some numeric value.
<h:outputText id="emailaddress"
value ="#{subsAlertsHelper.personEmail.substring(0,20)}"
rendered="#{subsAlertsHelper.personEmail.length() >20}" />
If I use == or != in rendered it is working fine. But for greaterthan and lessthan it is not giving the output. What could be the reason for that?
You have to use gt and lt operators.
Check out JavaServer Faces Expression Language Intro from Sun/Oracle. Precisely the Operators section.
rendered only accepts EL expression.
subsAlertsHelper.personEmail.length() is incorrect.
On the personEmail object, add a method getLength() witch returns the length
public int getLength(){ return this. length();}
Modify :
rendered="#{subsAlertsHelper.personEmail.length >20}"

Resources