scalaradio-buttonlift

Scala Lift: how to get ajaxRadio parameters


I have ajaxRadio ineach row of a table. when this Radio is selected, I want scala function to get two parameters: 1st one is the selected radio, 2nd one is the data key of the row. my source is as follows:

val radioList = List("wideArea", "oldArea","newArea")
def liftForm(xhtml: NodeSeq): NodeSeq = {  
    var areaList = newOrderList.map(values =>{
        <li id={values(1)} >
            <table>
                <thead></thead>
                <tbody>
                    <tr class = "real">
                        <td class="listImage">
                            <img class="areaImage" src={values(6)}/>
                        </td>
                        <td style="vertical-align:top;">
                            <tr><p class="areaName">{values(4)}</p></tr>
                            <tr><p class="areaComment">{values(5)}</p></tr>
                        </td>
                        <td class="listCheck" >
                            {ajaxButton(S.?("delete"), () => doDelete(values(1)), "class" -> "button delete")}
                        </td>
                    </tr>       
                    <tr>
                        <td></td>
                        <td>
                            {
                            val it = ajaxRadio[String](radioList,Box.legacyNullTest(values(2)),doRadioChange _).toForm.grouped(4)
                            for(i <- it)yield(<tr>{i.flatMap(y => <td> {y} </td>)}</tr>)
                            }
                        </td>
                    </tr>                   
                </tbody>
            </table>
        </li>})


    bind("list",xhtml,"areaList" -> <ul>{areaList}</ul>)

By doRadioChange _, I can only get selected radio. How can I get the the 2nd parameter: data key of the row. ie values(1)?


Solution

  • Your functions can close over all of the local state at that point in the function. You should be able to replace doRadioChange _ with:

    doRadioChange(_, values(1))
    

    Assuming, of course, that doRadioChange accepts the proper parameters.