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.

CoolBeans
  • 20,654
  • 10
  • 86
  • 101
  • If you are looking at this question you should also look at this sort of relevent question http://stackoverflow.com/questions/2766287/how-to-map-icefaces-iceselectinputdate-component-on-a-java-util-calendar-field – CoolBeans Aug 26 '10 at 23:21

1 Answers1

1

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
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Awesome BalusC. I get a classCastException on getValue() but I can fix that easily. Thanks a lot! – CoolBeans Aug 26 '10 at 21:08
  • 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 Aug 26 '10 at 21:19
  • Yes this is my second attempt at iceFaces so I am fairly novice myself. It has its pros and cons. – CoolBeans Aug 26 '10 at 21:25
  • 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 Aug 26 '10 at 23:08
  • 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 Aug 26 '10 at 23:23
  • Yup, the getClass() returns com.icesoft.faces.component.selectinputdate.SelectInputDate . – CoolBeans Aug 26 '10 at 23:29
  • Weird. What does its `getValue()` in turn return? – BalusC Aug 26 '10 at 23:37
  • I take that back. It's been a long day. The class is java.util.Date. Sorry, I was printing the wrong class. :-( – CoolBeans Aug 26 '10 at 23:41
  • 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 Aug 26 '10 at 23:47