0

I'm currently building an xhtml page based on Primefaces 3.5 (which I can't update...not lucky this time!).

In this page I need to build dynamically different datatables so I thought that unique way to achieve my task is through the binding method.

So I've made:

<p:dataTable id="bindQTable" var="item"
        value="#{bindingHtmlTableClass.items}"
        binding="#{bindingHtmlTableClass.dataTable}">

        <p:column headerText="Name Column">
            <h:outputText value="#{item}" />
        </p:column>
        <p:column>
            <p:commandButton value="remove"
                action="#{bindingHtmlTableClass.remove}" />
        </p:column>
    </p:dataTable>

and the bean:

@ManagedBean(name="bindingHtmlTableClass")
@RequestScoped
public class BindingHtmlTableClass implements Serializable{ 
    private List<String> items;  
    private DataTable dataTable;  

    @PostConstruct
    private void buildUp(){ 
        System.out.println("postconstruct!");
        items  = new ArrayList<String>();

        items.add("X");
        items.add("Y");
    }

     ...getters,setters... 
}

The problem now is that I would need to update the tables and especially after a poll period I need to update the values within them.

But i'm in a Request Scope and I can't use a View Scope because of binding. Is there a better way to implement such thing?

EDIT 4 BalusC: why i need binding the datatable? Because i need to show a datatable linked to a serie of different connection to different installation of RabbitMQ, which is not a known number. My boss asked me to put each RabbitMQ server in a different DataTable where each queue is represented in a different row. Each column needs to show actual queue size plus a button or more to manage the queue (purging, deleting...).

Thanks!

Black.Jack
  • 1,878
  • 2
  • 22
  • 39
  • This question is only answerable if you tell why exactly you thought that you need to bind a component to the bean, so that the right way for that can be answered without using binding. After that, changing the bean scope shouldn't be a problem anymore. My educated guess says that this answers your actual problem: http://stackoverflow.com/q/4994458 Regardless, this is food for read: http://stackoverflow.com/q/14911158 – BalusC Nov 02 '15 at 19:20
  • As per your edit, I wasn't really asking for the business reason, but for the technical reason. For example, is it because you need to be able to do a `dataTable.setSomething(something)` or so? If so, the answer would be to just use `` instead. – BalusC Nov 02 '15 at 19:27
  • Oh i see. I didn't put an actual instance of datatable and use a set method to fill it. No my need is to put different datatables (don't know how many...imagine a loop of n times with object value that has row values in it...) and be able to refresh their status like in a viewscope. Am I clear now? – Black.Jack Nov 02 '15 at 19:34
  • No, it's still not clear. Nonetheless, there's **nothing** which can only be achieved by fiddling with components in Java and not using declarative XHTML. So it's definitely possible to get rid of the binding on bean property altogether. – BalusC Nov 02 '15 at 19:36
  • Well...i'm the worst explainer of the Universe. Well..let's say you have to show an "x" number of datatables in a viewscope xhtml. What do u do? – Black.Jack Nov 02 '15 at 19:39
  • 1
    Just `` with a `private List>`? See also that food link http://stackoverflow.com/q/14911158 Ctrl+F on "dynamic model". – BalusC Nov 02 '15 at 19:40
  • Ok, that does sounds interesting and seems to fit my needs. Let me dig in articles and examples. thanks! – Black.Jack Nov 02 '15 at 19:45
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/94021/discussion-between-mark-and-balusc). – Black.Jack Nov 02 '15 at 20:12

0 Answers0