You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jorge Quiroga <jq...@pctltda.com> on 2006/01/13 16:11:15 UTC

Getting parameters for rendering dynamically

Hi Folks:

I'm trying to fill a "tab panel" with this code:

Page.html
         <table>
           <tr>
             <span jwcid="params@For" source="ognl:paramSelected" 
value="ognl:parametro">
               <td>
                 <span jwcid="@If" condition="ognl:parametro.hasCheckbox">
                   <span jwcid="@Checkbox" value="ognl:parametro.enabled"/>
                 </span>
                 <span class="labelClass" jwcid="@Insert" 
value="ognl:parametro.campo.displayName"/>
//This is a try using Hidden with listener
                 <span jwcid="@Hidden" 
listener="listener:onChangeParamAct" value="ognl:parametro.nomParametro"/>
                 <div jwcid="@RenderBlock" block="ognl:componente"/>
<block jwcid="alfanumerico@Block">
   <span jwcid="@TextField" value="ognl:parametro.valor" size="20"/>
</block>
<block jwcid="numerico@Block">
   <input jwcid="flo@ValidField" displayName="ognl:campo.displayName" 
value="ognl:parametro.valor" validator="floatValidator" type="text" 
size="20"/>
</block>
<block jwcid="entero@Block">
   <input jwcid="ent@ValidField" displayName="ognl:campo.displayName" 
value="ognl:parametro.valor" validator="entValidator" type="text" 
size="20"/>
</block>
<block jwcid="fecha@Block">
   <span jwcid="@DatePicker" value="ognl:parametro.fecValor"/>
</block>
<block jwcid="booleano@Block">
   <span jwcid="@Checkbox" value="ognl:valor"/>
</block>
<block jwcid="alfanumericoBoton@Block">
   <span jwcid="@TextField" enabled="false" value="ognl:parametro.valor" 
size="20"/>
   <input type="button" value="..." 
onClick="newWindow('/consultas/app?service=page&amp;page=LookupDialog&amp;session=T','','400','200','noresizable,scrollbars,status,notoolbar');"/>
</block>
<block jwcid="numericoBoton@Block">
   <input jwcid="@TextField" enabled="false" 
value="ognl:parametro.valor" type="text" size="20"/>
   <input type="button" value="..." 
onClick="newWindow('/consultas/app?service=page&amp;page=LookupDialog&amp;session=T','','400','200','noresizable,scrollbars,status,notoolbar');"/>
</block>
<block jwcid="enteroBoton@Block">
   <input jwcid="@TextField" enabled="false" 
value="ognl:parametro.valor" type="text" size="20"/>
   <input type="button" value="..." 
onClick="newWindow('/consultas/app?service=page&amp;page=LookupDialog&amp;session=T','','400','200','noresizable,scrollbars,status,notoolbar');"/>
</block>
<block jwcid="combo@Block">
   <select name="combo" jwcid="@PropertySelection" model="ognl:lookList" 
value="ognl:lookValue">
     <option selected=true value=0>Seleccione el valor</option>
   </select>
</block>
          </td>
        </span>
     </tr>
   </table>

I would prefer the blocks on another page, but for now I want that the 
page works.

.Page

<page-specification ...>

...

   <bean name="intValidator" 
class="org.apache.tapestry.valid.NumberValidator">
     <set name="required" value="false"/>
     <set name="valueType">"int"</set>
   </bean>

   <bean name="floatValidator" 
class="org.apache.tapestry.valid.NumberValidator">
     <set name="required" value="false"/>
     <set name="valueType">"float"</set>
   </bean>
   <property name="parametro"/>
...
</page-specification>


and .java

//This procedure was a trying, but is never called when I debug
// paramAct is a private instance variable

	public void onChangeParamAct(String nomParamAct){
		this.paramAct = 
(TParametro)getUser().getConsulta().getGrpParam(getSelectedGroup()).getParametro(nomParamAct); 

	}

//This is the function in charged of return the right block, but only 
return the default parameter that is defined on another part (when the 
tab is selected. The tab isn't a component yet).
	
	public Block getComponente(){
		StringBuffer sb = new StringBuffer();
		
		if (paramAct.getLookupTable()==null || 
paramAct.getLookupTable().equals("")){	
			if (paramAct.getCampo().getTipo()==pctTipos.TTipoDato.cadena){
				sb.append("alfanumerico");
			}
			else if (paramAct.getCampo().getTipo()==pctTipos.TTipoDato.entero){
				sb.append("numerico");
			}
			else if (paramAct.getCampo().getTipo()==pctTipos.TTipoDato.fecha){
				sb.append("fecha");
			}
			else if (paramAct.getCampo().getTipo()==pctTipos.TTipoDato.bool){
				sb.append("booleano");				
			}
			else sb.append("alfanumerico");
		}
		else{
			if (paramAct.getMostrarComo()==pctTipos.TTipoShow.combo){
				sb.append("combo");
			}
			else if (paramAct.getMostrarComo()==pctTipos.TTipoShow.dialog){
				if (paramAct.getCampo().getTipo()==pctTipos.TTipoDato.cadena){
					sb.append("alfanumericoBoton");
				}
				else if (paramAct.getCampo().getTipo()==pctTipos.TTipoDato.entero){
					sb.append("numericoBoton");
				}
				else if (paramAct.getCampo().getTipo()==pctTipos.TTipoDato.fecha){
					sb.append("fecha");
				}
				else if (paramAct.getCampo().getTipo()==pctTipos.TTipoDato.bool){
					sb.append("booleano");
				}
			}
		}

		return (Block)getComponent(sb.toString());
	}

I try these things but neither works

1) With a Hidden component inside For which value is 
parametro.nomParametro (parametro is a normal POJO) and 
listener="listener:onChangeParamAct", but never onChangeParamAct is called

2) change <div jwcid="@RenderBlock" 
block="ognl:componente(parametro.nomParametro)"/> and getComponente 
function change to receive the parameter directly. This throws an exception

3) Change <div jwcid="@RenderBlock" block="ognl:componente" 
paramAct="ognl:parametro:nomParametro"/> and put a Hidden component 
which value = "ognl:components.block.getParameter('paramAct')" and the 
listener of point 1), but throws an exception
   Unable to read OGNL expression '<parsed OGNL expression>' of 
$MainForm_269@3a1eb3[MainForm]: target is null for method getParameter

4) Others that I don´t remember at this moment

The problem in last instance is to pass something that while the For is 
performing, change the private instance variable or can pass something 
to getComponente function to "calculate" the correct block.

I'm doing something wrong or trying to do something in a wrong way. Can 
someone spotlight a viable solution or my mistake?

Thanks in advance

JQ


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Getting parameters for rendering dynamically

Posted by Jorge Quiroga <jq...@pctltda.com>.
Hello Sohail:

Maybe I wasn´t clear about my question, the problem isn't about tabs, is 
about fill them dynamically through a For component to select which 
block will be put inside the tab, the Tab isn´t important the important 
thing is to obtain a parameter to select the correct Block. I'll see the 
tabs components and replace my code if I like it.

Thanks.

JQ



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Getting parameters for rendering dynamically

Posted by Sohail Aslam <so...@techlogix.com>.
Please look at the TabSet component at 
http://equalitylearning.org/Tassel/app. Perhaps you could spot a 
solution in the TabSet code.

Regards,
Sohail Aslam
sohail.aslam at google mail dot calm

Jorge Quiroga wrote:
> Hi Folks:
> 
> I'm trying to fill a "tab panel" with this code:
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org