users@woodstock.java.net

Re: ayuda listas

From: Ken Paulsen <Ken.Paulsen_at_Sun.COM>
Date: Fri, 25 Apr 2008 22:49:35 -0700

Hi,

You are asking how to get the value of the 4 fields you are creating?

You can use a ValueExpression to map the data back to your List, or
anywhere else you would like. For example:

...
        caja=new TextField();
        caja.setId(dto.getId());
--> caja.setValueExpression("text", createVE("#{sessionBean.lista["
+ (idx++) + "].valor}"));
        this.getGridPanel1().getChildren().add(caja);
...

    private ValueExpression createVE(String exp) {
        FacesContext facesCtx = FacesContext.getCurrentInstance();
        return facesCtx.getApplication().getExpressionFactory().
            createValueExpression(facesCtx.getELContext(), exp,
Object.class);
    }

This will ensure the original object
(sessionBean.getLista().get(idx).setValor("<new value>")) is called.
However, you may want to use "binding" instead of "prerender".
"prerender" is not standard and may get invoked more than 1 time adding
too many fields to your page if it is refreshed.

I hope this helps you.

Good luck!

Ken Paulsen
https://jsftemplating.dev.java.net


jaider rodriguez wrote:
> hola ken.
>
> ya encontre la forma de pintar los controles ahora la duda que me asalta es
> como obtengo el valor que se digite en las cajas de texto o combos que se
> llegasen a pintar, te coloco el fragmento de codigo que pinta los controles,
> aclaro es solo un ejemplo , el ejemplo pinta cuatro cajas de texto y la
> funcion que te envio la llamo desde el prerender de la pagina
>
> public void crearTabla(){
> SessionBean1 f=this.getSessionBean1();
> TextField caja;
> ImageComponent imagen;
> for(DatosDto dto:f.getLista()){
> if(dto.getTipo().equals("TEXT")){
> caja=new TextField();
> caja.setId(dto.getId());
> caja.setText(dto.getValor());
> this.getGridPanel1().getChildren().add(caja);
> }else if(dto.getTipo().equals("IMAGE")){
> imagen=new ImageComponent();
> imagen.setId(dto.getId());
> imagen.setUrl(dto.getValor());
> this.getGridPanel1().getChildren().add(imagen);
> }
> }
> }
>
>
> la lista esta definida asi
>
>
> lista.clear();
> lista.add(new DatosDto("","compo1","TEXT"));
> lista.add(new DatosDto("","compo2","TEXT"));
> lista.add(new DatosDto("","compo3","TEXT"));
> lista.add(new DatosDto("","compo4","TEXT"));
>
>
> como obtengo el valor de lo que se digite sobre las cajas de texto
>
> gracias
> El Friday 25 April 2008 10:46:27 Ken Paulsen escribió:
>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>> <html>
>> <head>
>> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
>> <title></title>
>> </head>
>> <body bgcolor="#ffffff" text="#000000">
>> <br>
>> <a class="moz-txt-link-freetext"
>> href="http://www.freetranslation.com/">http://www.freetranslation.com/</a><
>> br> <br>
>> One way would be to use the "binding" attribute for a parent container
>> (like a PanelGroup) which uses the objects in the list to create child
>> components.&nbsp; There are other ways... if you have Java code showing
>> what you are trying to do, this would help us help you.<br>
>> <br>
>> Good luck!<br>
>> <br>
>> Ken<br>
>> <a class="moz-txt-link-freetext"
>> href="https://jsftemplating.dev.java.net">https://jsftemplating.dev.java.ne
>> t</a><br> <br>
>> Vanessa Black wrote:
>> <blockquote cite="mid:4811EFF3.5050404_at_Sun.COM" type="cite">
>> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
>> <br>
>> I believe this could serve as a translation into English<br>
>> <br>
>> -------------------------------<br>
>> <br>
>> Today I return to you all with the following problem<br>
>> <br>
>> I have a list which is filled with objects that have 3 properties. One
>> is called value, the second id, the third is type component(depending
>> on if you render a text box, or "combo"(?)&nbsp; or button). I'd like to
>> know how to run through the list and render the controls depending on
>> the corresponding type.<br>
>> <br>
>> Help please<br>
>> -------------------------------<br>
>> <br>
>> <a moz-do-not-send="true" class="moz-txt-link-abbreviated"
>>
>> href="mailto:jaider.rodriguez_at_creandosoft.com">jaider.rodriguez_at_creandosoft
>> .com</a> wrote:
>> <blockquote
>> cite="mid:20080424215129.2o9w4lfgwgcogwcc_at_webmail.creandosoft.com"
>> type="cite">Buen dia <br>
>> <br>
>> <br>
>> hoy recurro a ustedes por el siguiente problema. <br>
>> <br>
>> tengo una lista la cual esta lleno de objetos que tiene tres
>> propiedades una <br>
>> es llamado valor otro llamado id y el otro tipo de componente (si se
>> dibuja <br>
>> en una caja de texto o un combo o un boton etc), quisiera saber como
>> puedo <br>
>> hacer para recorrer esta lista y pintarla los controles segun el tipo
>> que les <br>
>> corresponde. <br>
>> <br>
>> ayuda por fa <br>
>> <br>
>> --------------------------------------------------------------------- <br>
>> To unsubscribe, e-mail: <a moz-do-not-send="true"
>> class="moz-txt-link-abbreviated"
>>
>> href="mailto:users-unsubscribe_at_woodstock.dev.java.net">users-unsubscribe_at_wo
>> odstock.dev.java.net</a> <br>
>> For additional commands, e-mail: <a moz-do-not-send="true"
>> class="moz-txt-link-abbreviated"
>>
>> href="mailto:users-help_at_woodstock.dev.java.net">users-help_at_woodstock.dev.ja
>> va.net</a> <br>
>> <br>
>> </blockquote>
>> <br>
>> <div class="moz-signature">-- <br>
>> <small style="font-family: palatino linotype;"><span
>> style="color: rgb(153, 153, 153);">Vanessa L. Black </span><br>
>> <span style="color: rgb(153, 153, 153);">Storage Platform Software
>> Group</span><br>
>> <span style="color: rgb(153, 153, 153);">Sun Microsystems Inc.</span><br>
>> <span style="color: rgb(153, 153, 153);">Broomfield , Colorado</span>
>> <br>
>> <span style="color: rgb(153, 153, 153);">x72984,
>> 303-272-2984</span></small> </div>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: <a class="moz-txt-link-abbreviated"
>> href="mailto:users-unsubscribe_at_woodstock.dev.java.net">users-unsubscribe_at_wo
>> odstock.dev.java.net</a> For additional commands, e-mail: <a
>> class="moz-txt-link-abbreviated"
>> href="mailto:users-help_at_woodstock.dev.java.net">users-help_at_woodstock.dev.ja
>> va.net</a> </blockquote>
>> </body>
>> </html>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
>> For additional commands, e-mail: users-help_at_woodstock.dev.java.net
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
> For additional commands, e-mail: users-help_at_woodstock.dev.java.net
>
>