Hello Stephen,
That's an extremely good question, but sadly without perfect answer for now.
So let split it in simpler question and explore some possibilities.
I can access the tr:column just fine, but where are the local values of each
row? I understand that no JSF component instances are created, but the
values sure must be accessible somewhere?!
That's a fair assumption and yes it's indeed possible but might requires the
usage of "binding". Assuming you used no startDepth or row (all rows shown).
private CoreTable table;
private CoreInputText inputStamp;
public void someMethodAccessingAllValues()
{
Object old = table.getRowKey(); // backup current model state
try
{
int count = table.getRowCount();
for (int i = 0; i < count; i++)
{
table.setRowIndex(i);
Object value = inputStamp.getLocalValue(); // Get the local value for
row i
}
}
finally
{
table.setRowKey(old); // restore model state
}
}
Although that works, it's certainly not "wow, thats' great!". Another way
I'm thinking about lately is the following. However, I did not implement it
yet so it might contains a loophole.
<my:form>
<f:facet name="validations">
<my:coherenceValidatorSet>
<my:sumValidator group="group1" max="10000"/>
<my:coherenceValidator group="group2" method="#{...}"/>
</my:coherenceValidatorSet>
</f:facet>
<tr:table ...>
<tr:column ...>
<tr:inputText ...>
<my:validationGroup name="group1"/>
</tr:inputText>
</tr:column>
</tr:table>
<tr:inputText ...>
<my:validationGroup name="group2"/>
</tr:inputText>
<tr:inputText ...>
<my:validationGroup name="group2"/>
</tr:inputText>
<tr:inputText ...>
<my:validationGroup name="group2"/>
</tr:inputText>
</my:form>
Where validationGroup is a validator regitering a <clientId, value> entry in
the request map under a groupId key (so the exact MapEntry is <groupId,
List<Pair<clientId, value>>) that is then used by coherence validators to
process multi field validations. The problems I still have are:
- Ordering: It's not easy to create a isGreaterThanPrevious validation
if the fields are not one after another in the page. Could add another
optional attribute to validationGroup though;
- Performance: If the coherence validator has to access the
UIComponent instances, it represents a lot of findComponent calls and I
cannot push the UIComponent instance in the request map entry because of
stamped components, relying on findComponent is mandatory to make sure the
data models are in sync.
Regards,
~ Simon
On 10/2/07, Stephen Friedrich < [EMAIL PROTECTED]> wrote:
>
> Maybe this is more a JSF question than related to Trinidad.
> (Or maybe not - I don't know how h:dataTable would work in contrast).
>
> In one column my tr:table contains inputText fields which contain integer
> values.
>
> I have to implement a validator that checks the sum of all numbers entered
> in that column.
>
> In my validator how the heck do I get access to the values of input fields
> in the column?
> I can access the tr:column just fine, but where are the local values of
> each row? I understand that no JSF component instances are created, but the
> values sure must be accessible somewhere?!
>
> And a minor related question: Is there a more elegant way to attach the
> validator as what I did currently? I added a dummy hidden field after the
> table just to add the validator to that field.
>