Mike, I really appreciate your help on all this. Things are becoming clearer, but I still have a question. Since the <h:inputHidden> field does not have an id associated with it, it should associate itself with closest JSF context in the hierarchy. If that is so, won't it be associated with the <jsf:view> and not the <h:dataTable>?

Maybe I need to do something like <h:dataTable id="foo" ...> </h:dataTable> and then do <h:inputHidden id="foo" name="criteria" ..> and then a new <h:dataTable id="foo">. I'll give that a try, but it seems inefficient to call the <h:dataTable> just to get the bean instantiated.

Maybe I'm just going about this all wrong. Is there a way in JSF to instantiate the bean and give it an id? Maybe I need to bring in the JSTL core?

-david-

Mike Kienenberger wrote:

inputText and other UIInput components do have to be in the form.   Is
that what you mean by "form context?"

<h:hiddenText name="criteria" value="value < 10"/> should work, and I
was going to suggest that.

Note that the values from components are set during the
applyValues/processValidations/updateModels phases, and not during the
renderResponse phase.   These phases won't get executed the first time
you request the page, so you'd need to make the default
fooBean.criteria value whatever you'd want it to be shown as on your
initial page rendering.

On 9/7/05, David Haynes <[EMAIL PROTECTED]> wrote:
Yes, but...
Doesn't the inputText need to be within a form context and propagated to
this page via an action event?
I want to specify the criteria on this page just prior to the
<h:dataTable entry.

If what you are proposing works, then I would simply do something like:
<h:hiddenText name="criteria" value="value < 10"/>
<h:dataTable ...

I'll give it a try, but I was sure inputText and hiddenText needed to be
in a form context...

-david-

Mike Kienenberger wrote:

JSF EL doesn't allow parameters in methods.

I don't mean creating a bunch of generateList*.... methods.

I mean creating one "public List getGenerateList()" method, and
providing the values it operates on separately.

For instance, you could use:

<h:inputText value="#{fooBean.criteriaString}>

(ie, fooBean.setCriteriaString(String criteriaString)

to set the criteria to anything you like.

On 9/7/05, David Haynes <[EMAIL PROTECTED]> wrote:


Doing it this way implies that I have a static filtering in mind. (i.e.
that I can create methods for generateListLikeFoo() and
generateListLessThan10(). What I was wondering is if you could have either:
a) a way of saying <h:dataTable
value="#{fooBean.generateList(parameters)}" ..., or
b) setting the parameters via setter methods and then generating the
list (using JSF).

In JSP, I could use the useBean to instantiate the fooBean and do all
sorts of set methods
to set up the criteria prior to the call to generateList().

So, is there a way to do it in JSF alone or do I need to combine JSP and
JSF to do this sort of thing?

-david-

Mike Kienenberger wrote:



You'd set the list to your datatable using something like this, with
getGeneratedList() using parameters already set on the fooBean or some
other backing bean to create the generated list (note that JSF may
call this method multiple times, so you probably want to cache the
list after creation).

<h:dataTable value="#{fooBean.generatedList}"

I don't quite understand how you plan to specify the criteria (In
code?  As the value binding of an inputText? Some other way?), so I
can't suggest how you'd populate fooBean's parameters.

On 9/7/05, David Haynes <[EMAIL PROTECTED]> wrote:




What, if any, is the best way to handle the following scenario?

I want to populate a dataTable based on a flexible query but the
criteria for the query is not within a form context.

For example:
I want to be able to set something like "where name like 'foo%'" as a
criteria and populate the dataTable and then reset the criteria to
"where value < 10' and present the dataTable again (on the same page).

This would be easy if I could parameterize the method call to build the
List for the dataTable but that doesn't seem to work. (i.e. <h:dataTable
value="#{fooBean.makeList("name like 'foo%'")}" is not accepted.

I then tried using an <f:param> to set the criteria value but the page
does not have the fooBean context instantiated until the
fooBean.makeList reference I can't set the criteria before that and the
empty constructor will build the default list before an <f:param> could
be applied.

I've got to be missing something obvious here. Pointers anyone?

Thanks.
-david-
















Reply via email to