• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling a managed bean method with parameters

 
David Carrascal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

It�s possible to do a method calling passing parameters?

I explain:

I have a data structure that has an Array of several registers, something similar to this one:

class Data{
private String x;
private String y;
private Tramo[] vTramos= new Tramo[24];
...
}

Well, I have a datatable and I need to show data contained in the array.
So I need something similar to this:

<rich:column width="15%" >
hutputText value="#{element.vTramos[0]}"/>
</rich:column>

otr this:

<rich:column width="15%" >
hutputText value="#{element.getVTramos[0]}"/>
</rich:column>

or
<rich:column width="15%" >
hutputText value="#{element.myMethod(0)}"/>
</rich:column>

No one of them worked...

Coul you help me?

Thank you in advance
 
Tim Holloway
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That mechanism isn't a "method call", strictly speaking. It's a property reference. A property reference uses the EL subsystem and the bean utilities to translated an expression in the form object.objectproperty into a parameterless invocation of the getObjectproperty() method of object. Or, when written to, it invokes the single-parameter "setObjectProperty()" method. It's not a general-purpose calling mechanism.

There isn't a parameterized calling mechanism for backing beans on JSF Views. There's object references, action method invocations and listener invocations, but not general logic calls.

The main reason for that is that if you're trying to do a call with parameters, you're putting program logic on the View. JSF is a fairly strict implementation of the MVC paradigm, and in MVC, business logic should be in the backing bean, controller logic should be in the controller (JSF applet and tags) and the view should have no logic at all. Although the view may invoke the view controller.

The closest thing to logic on the View (JSF page) you should normally have is things like the "rendered" attribute or AJAX operations. But these aren't stand-alone logic, they're requests back through the controller.
 
David Carrascal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hummm...

Ok, thanks Tim.

Well, then suppose that you have a datatable and you want to allow the edition of every field. That is, imagine a table composed for inputTexts only.
I know the number of rows, that is constant.

I would have a "Save" button too.

Then, how can I recover that data when I push the button?

I need to bind the table with a bean table object? or there is a better way
to do this?

Thanks in advance

David
 
David Carrascal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, that�s done!!

In fact, I�ve solve it binding a table.

Thanks!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!