0

I'm using JDeveloper 11.1.1.7.0

In the backing bean, I have a List attribute called myList, with related public and standard getter and setter methods, and I need to check if a String is contained inside it, in the context of an EL expression.

I have tried this expression:

disabled="#{myBean.myList.contains(label)}"

But it fails, and the message is that character ( has found instead of [ , . , or, eq, ...

I have tried to generate my custom TLD following this clear and well-explained steps How to create a custom EL function?, but I got an error becaus the function I declare is not found.

How can I check this condition (String contained in a List) in an EL expression? Thanks in advance. Regards

Community
  • 1
  • 1
yaki_nuka
  • 662
  • 3
  • 22
  • 39

3 Answers3

1

Did you try this:

disabled="#{empty myBean.myList[label]}"
Amr Gawish
  • 2,010
  • 1
  • 17
  • 27
  • Amr Gawish, thank you for your suggestion. I solved my issue, but your idea sounds well. Thank you – yaki_nuka Feb 06 '14 at 13:57
  • I'm glad you solved it, but if the answer I provided is also a valid answer, can you mark it as the right answer! – Amr Gawish Feb 06 '14 at 14:12
  • I found a solution before testing your approach. So, I put the link I followed to solve it. But thank you a lot again – yaki_nuka Feb 19 '14 at 14:41
0

If you really have an attribute of type List in your backing bean this should work.

You can also use it in the following ways:

disabled="#{myBean.myList.contains('the text')}"

disabled="#{not myBean.myList.contains(label)}" // contains not

disabled="#{myBean.myList.contains(label) eq true}"

disabled="#{!myBean.myList.contains(label)}" // contains not

If this doesn't work maybe something is wrong with your list.

See also:

Community
  • 1
  • 1
unwichtich
  • 13,143
  • 2
  • 46
  • 60
  • thank you for your suggestions, but they don't work for me. An EL Expression can't pass parameters when invoking a function, but there is a tricky idea to make something like that. Thank you again – yaki_nuka Feb 06 '14 at 08:50
0

An EL Expression can't pass parameters when invoking a function, but I found this link which explain an idea to simulate a passing-parameters by using a Map. It works perfect for me: Pass parameters from EL to a method: Simulation

yaki_nuka
  • 662
  • 3
  • 22
  • 39