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 8712505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:07:25+00:00 2026-06-13T05:07:25+00:00

I access the Attributes of my composite component this way: enum PropertyKeys {comments, currentUserUsername}

  • 0

I access the Attributes of my composite component this way:

enum PropertyKeys {comments, currentUserUsername}

@SuppressWarnings("unchecked")
private <T> T getAttribute(PropertyKeys propertyKey){
    return (T) getStateHelper().eval(propertyKey);
}

private <T> void setAttribute(PropertyKeys propertyKey, T value){
    getStateHelper().put(propertyKey, value);
}

private List<Comment> getComments() {
    return getAttribute(PropertyKeys.comments);
}

private String getCurrentUserUsername() {
    return getAttribute(PropertyKeys.currentUserUsername);
}

This works for the list (comment) but not for the String (CurrentUserUsername), when i pass the username this way:

<tr:commentBox comments="#{main.comments}" currentUserUsername="Hans" [...] />

But when i pass it this way:

<tr:commentBox comments="#{main.comments}" currentUserUsername="#{'Hans'}" [...] />

It works.

I dont want that anybody who will use my component have to put strings in as EL …

Is there a solution so i can pass strings in as in the first snippet ?

  • 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-06-13T05:07:26+00:00Added an answer on June 13, 2026 at 5:07 am

    I found a workarround but i don’t think that i should do it this way.. :

    @SuppressWarnings("unchecked")
    private <T> T getAttribute(PropertyKeys propertyKey){
        T result = (T) getStateHelper().eval(propertyKey);
    
        if (result == null) {
            result = (T) this.getAttributes().get(propertyKey + "");
        }
    
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In PHP I can access class attributes like this: <?php // very simple :)
I am trying to call a inherited method that must access private attributes from
In JSP page we can access to attributes using this: ${name} . But if
Is there a way to access the attributes of the controller action parameter currently
this is a best practices type of question. I want to access the attributes
Is there a practical way to access the attributes decorating a controller or action
How do you use variables to access Object attributes? Suppose I have an Object
How can I access metadata (dataannotations attributes) in my asp.net mvc model class from
I can't access my model's attributes in the after_create callback... seems like I should
How would I access(throught JavaScript) an anchor element without it having any attributes except

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.