0

I'm trying to do something I would expect to be relatively easy. Essentially I have an object that looks like this:

public class Attribute {
   public UIInput getInput();
   public void setInput(UIInput input);
   public String getName();
   public void setName(String name);
}

I have a List of these on a bean, and I'm trying to iterate through the list and display it.

Here's an example (I've also tried p:dataTable)

<ui:repeat value="#{someBean.attributes}" var="a">
   <div>#{a.name} <ui:fragment binding="#{a.input}" /> </div>
</ui:repeat>

However ui:fragment doesn't work that way, it is binded before the Request Value stage (apparently). I've also tried creating a backing DataTable and adding data that way, but it seems like I can't add custom rows with this methodology:

for (Attribute attr : bean.getAttributes) {
   Row r = new Row();
   r.setCell(0, attr.getName());
   r.setCell(1, attr.getInput());
   table.getRows().add( r );
}

I've searched this to death, and I can't find anything! I wanted to avoid writing my own Component which is just a wrapper to another component... but If I have to go down that road I will.

ClickerMonkey
  • 1,881
  • 16
  • 13
  • The code indeed doesn't make any sense. There's only one of that component in the JSF component tree, not one for each of iterated item. It's just that this component is reused multiple times during generating the HTML output based on the JSF component tree. I suggest you to edit and revise this question and ask how to solve a specific concrete functional requirement instead of asking how to achieve a solution of which you thought that it's the right solution (but after all isn't). – BalusC Sep 24 '12 at 20:48
  • For a related topic, read this answer: http://stackoverflow.com/a/3343681. Just read "binding" instead of "JSTL" in this answer to better understand what is really happening here. If I *guess* right what you really need, then you may find this answer helpful: http://stackoverflow.com/a/11884271 Btw: you can safely replace `` by `` here. – BalusC Sep 24 '12 at 20:48
  • Thank you BalusC! I was hoping you would help with this, I ended up making a composite component that had 30 different input types, and only had one of them render depending on the data type. Very messy but it works. – ClickerMonkey Sep 24 '12 at 20:52
  • Oh, those answers are maybe more helpful then: http://stackoverflow.com/search?q=user:157882+[dynamic-forms] – BalusC Sep 24 '12 at 20:53
  • Yup, that's exactly what I ended up doing. I also made an interface "Field" which handles string-object conversion so I can store the string representation in the database. – ClickerMonkey Sep 24 '12 at 20:55

0 Answers0