tags:

views:

32

answers:

1

My ice:dataTable looks like below:-

<ice:dataTable id="someTbl" var="someVar" value="#{someBean.someList}" >
   <ice:column>  
       <f:facet name="header"> <ice:outputText value="#{msgs.tblCol1}"> </f:facet>
       <ice:outputText value="#{someVar.name}"/>
    </ice:column>
   <ice:column>  
       <f:facet name="header"> <ice:outputText value="#{msgs.tblCol2}"> </f:facet>
        <ice:selectInputDate id="startCal" value="#{someVar.startTime}"
                 renderAsPopup="true" renderYearAsDropdown="true"    
                 renderMonthAsDropdown="true" partialSubmit="true" >
                 <f:convertDateTime pattern="MM/dd/yyyy HH:mm" type="date" timeZone="EST"/> 
        </ice:selectInputDate>
    </ice:column>
    <ice:column>  
       <f:facet name="header"> <ice:outputText value="#{msgs.tblCol3}"> </f:facet>
        <ice:selectInputDate id="endCal" value="#{someVar.endTime}"
                 renderAsPopup="true" renderYearAsDropdown="true"    
                 renderMonthAsDropdown="true" partialSubmit="true" validator="#{someBean.validateEndtime}">
                 <f:convertDateTime pattern="MM/dd/yyyy HH:mm" type="date" timeZone="EST"/> 
        </ice:selectInputDate>
    </ice:column>
</ice:dataTable> 

When the validator on the second calendar (id "endCal") on the row is invoked, I want to get the value of the first calendar (id "startCal") on that row in my backing bean. Is there a way to accomplish that? I was wondering about ice:rowSelector but I noticed I can only get the rowId of the selected which means I will have to traverse through the "someBean.someList" in the validator method to find the values for that entry.

+1  A: 

First bind the first input to bean:

<ice:selectInputDate id="startCal" binding="#{someBean.startCalComponent}" ... >

with this property:

private UIInput startCalComponent; // +getter+setter

Then, in your SomeBean#validateEndtime() method do:

Date startTime = (Date) startCalComponent.getValue();
BalusC
Awesome BalusC. I get a classCastException on getValue() but I can fix that easily. Thanks a lot!
CoolBeans
You're welcome. I don't do IceFaces, so I don't know from top of head what `selectInputDate` is expecting. I just plain assumed it to be `java.util.Date`.
BalusC
Yes this is my second attempt at iceFaces so I am fairly novice myself. It has its pros and cons.
CoolBeans
Looks like it comes in as a com.icesoft.faces.component.selectinputdate.SelectInputDate . So I gotta figure out a way to convert that to java.util.Date .
CoolBeans
Aren't you confusing it with the `startCalComponent`? You should more be interested in the outcome of `getValue()`. Use `startCalComponent.getValue().getClass()` to learn more about its actual type.
BalusC
Yup, the getClass() returns com.icesoft.faces.component.selectinputdate.SelectInputDate .
CoolBeans
Weird. What does its `getValue()` in turn return?
BalusC
I take that back. It's been a long day. The class is java.util.Date. Sorry, I was printing the wrong class. :-(
CoolBeans
Also I figured why I got the classCastException the first time. For some reason Eclipse imported the data as java.sql.Date as opposed to java.util.Date. I should have noticed that the first thing. I have seen it doing it before. Phew .. things are working good again.
CoolBeans
You're welcome and sleep well soon ;)
BalusC