Arrays de VOs no struts

0 respostas
v1c70r_f

Então pessoal, tô com uma dúvida cruel aqui.

Meu caso é o seguinte, pra popular meu VO de acordo com o form-bean tem algumas premissas neh, por exemplo, se eu tiver que popular um VO que está dentro de um VO que é um atributo do meu form-bean, ao declará-lo no .java eu devo inicializá-lo:
public class DadosVO implements ValueObject {
	
	private ApoliceVO apolice = null;
	.
	.
	.
	}
	public class ApoliceVO implements ValueObject{
	
		private SeguradoVO segurado = new SeguradoVO();
	.
	.
	.
	}
No caso, se eu não tivesse inicializado o 'SeguradoVO', como no struts-config o mapeamento só mapeou o atributo 'apolice', quando eu tenho um input com o id e name = apolice.segurado.nome, ao acessar o método setNome ele apresentaria erro, por tentar acessar um objeto nulo. (um dos casos com erro BeansPopulate).

Até aí tudo bem, porém se no caso o meu VO segurado fosse um ARRAY de SeguradoVO eu até posso inicializá-lo com o tamanho, porém para cada posição eu teria que instanciar um objeto, ou seja, se meu VO tiver 50 posições, mesmo que use só uma eu teria que inicializar o array inteiro.

Andei olhando o .dtd do struts config e nele tem uma parte que diz o seguinte:
<!-- The "form-property" element describes a JavaBean property that can be used to
     configure an instance of a DynaActionForm or a subclass thereof. This element
     is only utilized when the "type" attribute of the enclosing "form-bean" element
     is [org.apache.struts.action.DynaActionForm] or a subclass of DynaActionForm. If
     a custom DynaActionForm subclass is used, then the "dynamic" attribute of the
     enclosing <form-bean> element must be set to "true". Since Struts 1.1.

     className       The configuration bean for this form property object. If
                     specified, the object must be a subclass of the default
                     configuration bean.
                     ["org.apache.struts.config.FormPropertyConfig"]

     initial         String representation of the initial value for this property.
                     If not specified, primitives will be initialized to zero and
                     objects initialized to the zero-argument instantiation of that
                     object class.  For example, Strings will be initialized to ""


     name            The name of the JavaBean property described by this element.

     size            The number of array elements to create if the value of the
                     "type" attribute specifies an array, but there is no value
                     specified for the "initial" attribute.

     type            Fully qualified Java class name of the field underlying this
                     property, optionally followed by "[]" to indicate that the
                     field is indexed.
-->
Pelo que eu entendi, utilizando o atributo className  um meio de configurar o bean, porém não encontrei nada a respeito.

Vocês  viram algo a respeito??? Possuem alguma idéia de como implementar isso?
Criado 23 de maio de 2007
Respostas 0
Participantes 1