You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by angeloimm <an...@libero.it> on 2005/01/17 12:25:36 UTC

Input type button

Hi all... i'm using cocoon cforms version 2.1.5......i need to insert an input type="button" in my form; well in order to do this i have done this template:
     <fd:repeater id="allegato" initial-size="0">
      <fd:label>Allegato</fd:label>
      <fd:hint>Allegato</fd:hint>
      <fd:help>Allegato</fd:help>
      <fd:widgets>
        <fd:booleanfield id="selezione">
          <fd:label>selezione*****</fd:label>
        </fd:booleanfield>
        <fd:field id="nome" required="true">
          <fd:label>nome</fd:label>
          <fd:datatype base="string"/>
        </fd:field>
<!-- ####### I'LD LIKE THAT THIS FIELD IS A BUTTON ######-->
        <fd:field id="allegami">
          <fd:label>Allega File</fd:label>
          <fd:datatype base="string"/>
        </fd:field>
        <fd:row-action id="delete" action-command="delete">
          <fd:label>Cancella</fd:label>
          <fd:hint>Cancella la proprieta'</fd:hint>
        </fd:row-action>
        <fd:row-action id="moveUp" action-command="move-up">
          <fd:label>In Alto</fd:label>
        </fd:row-action>
        <fd:row-action id="moveDown" action-command="move-down">
          <fd:label>In Basso</fd:label>
        </fd:row-action>
      </fd:widgets>
    </fd:repeater>


then i have this jx:

<ft:repeater-widget xmlns:ft="http://apache.org/cocoon/forms/1.0#template" id="allegato">
	<tr>
	<td style="padding:2px;width:100px;border-bottom:1px solid #737373;">
        <ft:widget xmlns:ft="http://apache.org/cocoon/forms/1.0#template" id="nome">
          <fi:styling xmlns:fi="http://apache.org/cocoon/forms/1.0#instance" type="hidden" />
        </ft:widget>
        <div id="allegato_FILE_div" style="display:block;">
          <p style="border-bottom:1px solid black">
          </p>
        </div>
      </td>	

           <td style="border:1px solid #737373; width:440px;">
	<ft:widget xmlns:ft="http://apache.org/cocoon/forms/1.0#template" id="delete">
		<fi:styling xmlns:fi="http://apache.org/cocoon/forms/1.0#instance" class="button"/>
	</ft:widget>
	<ft:widget xmlns:ft="http://apache.org/cocoon/forms/1.0#template" id="moveUp">
		<fi:styling xmlns:fi="http://apache.org/cocoon/forms/1.0#instance" class="button"/>
	</ft:widget>
	<ft:widget xmlns:ft="http://apache.org/cocoon/forms/1.0#template" id="moveDown">
		<fi:styling xmlns:fi="http://apache.org/cocoon/forms/1.0#instance" class="button"/>
	</ft:widget>
	       <br />
<!-- ######## HERE I USE FI STYLING FOR SETTING INPUT TYPE="BUTTON" ######## -->
	<ft:widget xmlns:ft="http://apache.org/cocoon/forms/1.0#template" id="allegami">
		<fi:styling xmlns:fi="http://apache.org/cocoon/forms/1.0#instance" type="button" value="Scegli File" class="button" onclick="javascript:ShowPopUp('/Nikko/BM/viewcontent.do?path=/&amp;amp;typeresource=file&amp;amp;campo=' + this.name.replace('allegami','name') + '_FILE')"/>
	</ft:widget>
	      </td>
          </tr>
        </ft:repeater-widget>

Well it seems to me all good but if i go an see the form i see the fiel "allegami" as an input type="text"; in fact this is my html output:

<input type="text" title="" value="Scegli File" id="allegato.0.allegami" name="allegato.0.allegami" class="button" onclick="javascript:ShowPopUp('/Nikko/BM/viewcontent.do?path=/&amp;amp;typeresource=file&amp;amp;campo=' + this.name.replace('allegami','name') + '_FILE')">

but i wanted:

<input type="button" title="" value="Scegli File" id="allegato.0.allegami" name="allegato.0.allegami" class="button" onclick="javascript:ShowPopUp('/Nikko/BM/viewcontent.do?path=/&amp;amp;typeresource=file&amp;amp;campo=' + this.name.replace('allegami','name') + '_FILE')">

Can anybody help me?
Thanks



____________________________________________________________
Libero ADSL: 3 mesi gratis e navighi a 1.2 Mega. E poi hai l'Adsl senza limiti a meno di 1 euro al giorno. 
Abbonati subito senza costi di attivazione su http://www.libero.it




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Input type button

Posted by Mark Lundquist <ml...@wrinkledog.com>.
Hello,

On Jan 17, 2005, at 3:25 AM, angeloimm wrote:

> Hi all... i'm using cocoon cforms version 2.1.5......i need to insert  
> an input type="button" in my form; well in order to do this i have  
> done this template:
>     .
>     .
>     .
> <!-- ####### I'LD LIKE THAT THIS FIELD IS A BUTTON ######-->
>         <fd:field id="allegami">
>           <fd:label>Allega File</fd:label>
>           <fd:datatype base="string"/>
>         </fd:field>
> [...snip]
>
> then i have this jx:nal
>
> <!-- ######## HERE I USE FI STYLING FOR SETTING INPUT TYPE="BUTTON"  
> ######## -->
> 	<ft:widget xmlns:ft="http://apache.org/cocoon/forms/1.0#template"  
> id="allegami">
> 		<fi:styling xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"  
> type="button" value="Scegli File" class="button"  
> onclick="javascript:ShowPopUp('/Nikko/BM/viewcontent.do?path=/&amp; 
> amp;typeresource=file&amp;amp;campo=' +  
> this.name.replace('allegami','name') + '_FILE')"/>
> 	</ft:widget>
>
>
> Well it seems to me all good but if i go an see the form i see the  
> fiel "allegami" as an input type="text"; in fact this is my html  
> output:
> o
> <input type="text" title="" value="Scegli File"  
> id="allegato.0.allegami" name="allegato.0.allegami" class="button"  
> onclick="javascript:ShowPopUp('/Nikko/BM/viewcontent.do?path=/&amp; 
> amp;typeresource=file&amp;amp;campo=' +  
> this.name.replace('allegami','name') + '_FILE')">

Right.  <fi:styling> sort of assumes that you're supplying attributes  
that are appropriate for the widget, and in this case you have the  
wrong widget :-).  <fi:styling> can't change one widget into another,  
and you can't use <fd:field> to get a button because a button doesn't  
conform to the semantics of a Field.

CForms has two button widgets: Submit and Action, and the difference is  
that Submit triggers form validation and (if valid) a return from  
showForm(), while Action can optionally trigger validation and doesn't  
result in a return from showForm.  So, you use Action for server-side  
interactions (e.g. coded in flowscript) in which the form is  
redisplayed.

They key word there is "server side".  If your button doesn't submit  
the form but only does its client-side onclick() thing, then really it  
isn't a CForms button at all!  It's just a button on your page, so you  
should create it the same way you do any other "stuff that is just on  
the page" — just write the HTML in the form template.  Makes sense?

Cheers,
-ml-


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org