java - How can I access methods based on strings in an array? -


Hello!

I'm also not sure that this is possible, but hopefully it's in Java I know that I use the variable variable and dynamically using a variable But I have read that Java is not possible in a different question.

I have an array of strings that contain the status of the checkbox in my JSF GUI. If all checkboxes are set then the values ​​of different checkboxes will be filled with strings.

The labels and values ​​of the checkbox are created by looping through an array that looks like this:

{"title", "requestTitle"}, {"" date "," Request "), {" date added "," dub "}, {" title "," requestTitle "}, {" process "," process id "}, ..., ..., ...}; < / Code>

Then I repeat through the array and I create JSF SelectItems:

 for  (int i = 0; i & lt; oVERVIEW_FIELDS Length; i ++) {SelectItem item = new selection item (overview_FIELDS [i] [0], overview_FIELDS [i] [1]); GetFields () (item) Add;}  

Problems and current solutions (hopefully someone can help me do it better again:

 

and similarly continues for 11 booleans. I do not like this solution, and I see similar patterns in other beans in my system.

Does anyone know that this is a better solution? The booleans are the control columns where I set their rendered fields for correct / incorrect according to the check box array. / P>

I was hoping in JSF EL that I can use visible file types and include the method, thus returning the actual or incorrect object or object. Y. It does not seem to work though, and EL does not use me to include the method.

I am currently using:

  rendered = "# {and I tried this code with:  
  provided Done = "# {overviewFilterBean.visibleFields.contains ['dob']}" overviewfilterben.dob} " 

& gt;

Now I tried to use my final array and tried to set the boolean according to the getFields (). In this (overview_FIELDS [i] [1]) , but how can I make it possible?

The part actual and part proxy code is as follows (I was now aiming for the solution):

 for  (int i = 0; i & lt; OVERVIEW_FIELDS.length; i ++) {if (item.quilues (overview_fileds [i] [1])) {setOVERVIEW_FIELDS [i] [1] (true); }}  

Big question:

Do I have a way to use value from OVERVIEW_FIELDS [i] [1 ] to set the right boolean variable or can I change it in the map and can use JSF EL to check the key in the message?

Thank you for your time, and sorry to get a short point to write such a long question:

Edit:

As a result of the reflection method, 5 exceptions, big blocks of code handling and those people also said that it is an expensive method. This makes me believe that either the best way to do this is by using my old solution or map. I am trying to resolve the map I =)

You can always store values ​​in the map However if you want to apply methodname methods based on the string, use the reflection


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -