Hi Matthias,

i created a small test page (see attached files), but i can't reproduce
your problem. All works as expected, also when validation fails.

Please provide more info about what you are doing and your tree structure.

Regards,
  Volker

Matthias Kahlau wrote:
>>There's a use case where I encounter a problem with my solution. When a
>>validation error occurs in the process validations phase, all the radio
>>buttons shown in the HtmlDataTable aren't rendered when the page is
>>redisplayed.
>>
>>Why I try to evaluate the HtmlSelectOneRadio components in this
>>view state,
>>I get a runtime error because the components aren't fully initialized. The
>>component values / value classes are of the following type, for example:
>>
>>value = [EMAIL PROTECTED]
>>value class = org.apache.myfaces.renderkit.RendererUtils$1
> 
> 
> 
> Is it possible to solve this problem, or is this a dead end?
> 
> 
> Regards,
> 
> Matthias
> 
> 

-- 
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by
concatenating my forename to my senders domain.
<%@ page session="false" contentType="text/html;charset=utf-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk"; prefix="t"%>
<html>

<!--
/*
 * Copyright 2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
//-->

<[EMAIL PROTECTED] file="inc/head.inc" %>

<body>

<!--
managed beans used:
    countryList
-->

<f:view>

  <h:form id="form">
    <f:loadBundle 
basename="org.apache.myfaces.examples.resource.example_messages" 
var="example_messages"/>

    <t:selectOneRadio id="select" value="#{testBean.value}" layout="spread" 
validator="#{testBean.validateInput}">
      <f:selectItems value="#{testBean.items}" />
    </t:selectOneRadio>

                <t:dataTable id="data"
                        var="row"
                        value="#{testBean.values}"
                        rowIndexVar="rowIndex"
                        preserveDataModel="true" >
                   <h:column>
                       <f:facet name="header">
                          <h:outputText value="header 1" />
                       </f:facet>
                       <h:outputText value="#{row}" />
                   </h:column>

                   <h:column>
                       <f:facet name="header">
                          <h:outputText value="header 2" />
                       </f:facet>
                       <t:radio for=":form:select" index="#{rowIndex}"/>
                   </h:column>

                </t:dataTable>

  <p/>
  <h:outputText value="aktuell ist #{testBean.value}"/>
  <p/>
  <h:commandButton value="submit"/>

  <h:messages />

  </h:form>
</f:view>

</body>

</html>
package org.apache.myfaces.examples.test;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.faces.model.SelectItem;
import javax.faces.context.FacesContext;
import javax.faces.component.UIComponent;
import javax.faces.application.FacesMessage;
import java.util.List;
import java.util.ArrayList;

/**
 * Created by IntelliJ IDEA.
 * User: weber
 * Date: 12.02.2006
 * Time: 21:11:09
 * To change this template use File | Settings | File Templates.
 */
public class TestBean {

  private static final Log LOG = LogFactory.getLog(TestBean.class);

  List values ;
  SelectItem[] items;

  Object value;

  public TestBean() {
    values = new ArrayList();

    values.add("eins");
    values.add("zwei");
    values.add("drei");
    values.add("vier");

    items = new SelectItem[values.size()];

    for (int i = 0; i< items.length; i++) {
      items[i] = new SelectItem(values.get(i), values.get(i).toString().toUpperCase());
    }
  }

  public void validateInput(FacesContext facesContext, UIComponent component, Object testValue) {

    LOG.info("testValue = \"" + testValue + "\"");

    if (values.get(values.size() - 1).equals(testValue)) {
      facesContext.addMessage(null, new FacesMessage("don't select last row!"));
      facesContext.renderResponse();
    }

  }

  public List getValues() {
    return values;
  }

  public void setValues(List values) {
    this.values = values;
  }

  public SelectItem[] getItems() {
    return items;
  }

  public void setItems(SelectItem[] items) {
    this.items = items;
  }

  public Object getValue() {
    return value;
  }

  public void setValue(Object value) {
    this.value = value;
  }
}

Reply via email to