Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6957745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:02:52+00:00 2026-05-27T15:02:52+00:00

i was wondering if there’s contains method for collections/array in EL 2.2 or i

  • 0

i was wondering if there’s contains method for collections/array in EL 2.2
or i will have to make a custom one ?

REQUIREMENT: i have a string array, and i want to find if it contains a specific string.

CASE: i am looping on list of input checkboxes to render them, and i want to check the current checkbox, if it’s value exists in the array of checkboxes.

UPDATE:

  • is such method is available in EL?

  • If such method is not available, then please provide your suggestion for best performance method for a string array contains an element.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:02:52+00:00Added an answer on May 27, 2026 at 3:02 pm

    For a Collection it’s easy, just use the Colleciton#contains() method in EL.

    <h:panelGroup id="p1" rendered="#{bean.panels.contains('p1')}">...</h:panelGroup>
    <h:panelGroup id="p2" rendered="#{bean.panels.contains('p2')}">...</h:panelGroup>
    <h:panelGroup id="p3" rendered="#{bean.panels.contains('p3')}">...</h:panelGroup>
    

    For an Object[] (array), you’d need a minimum of EL 3.0 and utilize its new Lambda support.

    <h:panelGroup id="p1" rendered="#{bean.panels.stream().anyMatch(v -> v == 'p1').get()}">...</h:panelGroup>
    <h:panelGroup id="p2" rendered="#{bean.panels.stream().anyMatch(v -> v == 'p2').get()}">...</h:panelGroup>
    <h:panelGroup id="p3" rendered="#{bean.panels.stream().anyMatch(v -> v == 'p3').get()}">...</h:panelGroup>
    

    If you’re not on EL 3.0 yet, you’d need to create a custom EL function. For a concrete example, see How to create a custom EL function to invoke a static method? E.g.

    public static boolean contains(Object[] array, Object item) {
        return Arrays.asList(array).contains(item);
    }
    

    which is registered as

    <function>
        <function-name>contains</function-name>
        <function-class>com.example.Functions</function-class>
        <function-signature>boolean contains(java.lang.Object[], java.lang.Object)</function-signature>
    </function>
    

    and to be used as

    <h:panelGroup ... rendered="#{func:contains(bean.panels, 'u1')}">
    

    This is not available in JSTL. There’s a fn:contains(), but that works on String values only.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

wondering if there's any way to make it so that a list I have
Wondering if there is a fast way, maybe with linq?, to convert a Dictionary<string,string>
just wondering is there any chance that their will be a dummy database schemas
Wondering if there is a way to have multicolor text for ASP.NET Button Text.
Just wondering if there's a preferred method or Best Practice for storing Updated By
Just wondering if there's a way to make Visual Studio 2008 Express Edition generate
Wondering if there is an existing ring buffer in .NET that has only one
just wondering is there a way to List all objects in database which have
Wondering if there's someone here with some experience with gzip format. I have a
Wondering if there is any Text to Speech software available as a plug in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.