You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by oceatoon <t....@systheo.com> on 2004/11/27 13:37:47 UTC

Repeater addRow action button to link??

Hi everyone

I tried posting this too the user list but got no answer hope I'll be
luckier in dev :) 

in our website, I tried to make a link that launches the addrow action
instead of the usual submit type button launching on my repeater,
but I can't get it to launch the action?? 

this is what is originaly done
<input name="addroom" type="submit" id="addroom" value="Add a Room" />

and I would want
<a href="javascript:document.forms[0].submit();" id="addroom">Add Room</a>
but this has a complete submit action,  and not just addrow submit ???

 Following the event handler docs, is it possible to connect my link to the
list of event listenners or actions define for the addrow? in my case
addroom ?

Thanks 
Regards
Tibor


Re: Repeater addRow action button to link??

Posted by oceatoon <t....@systheo.com>.
Sylvain Wallez wrote:

> oceatoon wrote:
> 
>>I tried to retreive your latest update of field styling but didn't find
>>the new template you described , is it all ready up on svn ?
>>  
>>
> 
> Well, it was for a few hours, and then got overriden by Reinhard's sync
> between 2.2 and 2.1 :-/
> 
> I committed it again, and here's the template just in case Reinhard does
> some more syncing ;-)
> 
>   <xsl:template match="fi:action[fi:styling/@type = 'link']"
> priority="1">
>     <a title="{fi:hint}" href="#" onclick="forms_submitForm(this,
> '{@id}'); return false">
>       <xsl:apply-templates select="." mode="styling"/>
>       <xsl:copy-of select="fi:label/node()"/>
>     </a>
>   </xsl:template>
> 
> The difference I see is that the form_submitForm is in "onclick" and not
> in "href".
> 
> Also, be careful of not declaring a widget named "submit" as it will
> override the submit() function of the form object...
> 
> Sylvain
> 
This time all went well :)
indeed the onclick solved the problem
Thx
Regards 
Tibor



Re: Repeater addRow action button to link??

Posted by Sylvain Wallez <sy...@apache.org>.
oceatoon wrote:

>I tried to retreive your latest update of field styling but didn't find the
>new template you described , is it all ready up on svn ?
>  
>

Well, it was for a few hours, and then got overriden by Reinhard's sync 
between 2.2 and 2.1 :-/

I committed it again, and here's the template just in case Reinhard does 
some more syncing ;-)

  <xsl:template match="fi:action[fi:styling/@type = 'link']" 
priority="1">      
    <a title="{fi:hint}" href="#" onclick="forms_submitForm(this, 
'{@id}'); return false">      
      <xsl:apply-templates select="." mode="styling"/>      
      <xsl:copy-of select="fi:label/node()"/>      
    </a>
  </xsl:template>

The difference I see is that the form_submitForm is in "onclick" and not 
in "href".

Also, be careful of not declaring a widget named "submit" as it will 
override the submit() function of the form object...

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Re: Repeater addRow action button to link??

Posted by oceatoon <t....@systheo.com>.
I tried to retreive your latest update of field styling but didn't find the
new template you described , is it all ready up on svn ?
Thx
Tibor


Re: Repeater addRow action button to link??

Posted by oceatoon <t....@systheo.com>.
Well this seemed like a easy solution
but I was over enthousiastic :)

I implemented my xsl
<xsl:template match="fi:action[fi:styling/@type='link']">
<div style="float:left">
<a id="{@id}" name="{@id}" title="{fi:hint}"
href="javascript:forms_submitForm(this,'{@id}')">                
<xsl:value-of select="@id"/>
<xsl:apply-templates select="." mode="styling"/> 
</a>
</div>
</xsl:template>

I end up with the right link with a call to forms_submitForm
but I don't understand why it doesn't execute the function???

Maybe you would have an idea ?
Thx 
Tibor

> Sylvain Wallez wrote:
> 
>> oceatoon wrote:
>> 
>>>Hi everyone
>>>
>>>I tried posting this too the user list but got no answer hope I'll be
>>>luckier in dev :)
>>>
>>>in our website, I tried to make a link that launches the addrow action
>>>instead of the usual submit type button launching on my repeater,
>>>but I can't get it to launch the action??
>>>
>>>this is what is originaly done
>>><input name="addroom" type="submit" id="addroom" value="Add a Room" />
>>>
>>>and I would want
>>><a href="javascript:document.forms[0].submit();" id="addroom">Add
>>>Room</a>
>>>but this has a complete submit action,  and not just addrow submit ???
>>>
>>> Following the event handler docs, is it possible to connect my link to
>>> the
>>>list of event listenners or actions define for the addrow? in my case
>>>addroom ?
>>>  
>>>
>> 
>> Yes. Please have a look at how is implemented "submit-on-change" in
>> forms-field-styling.xsl: you have to call "forms_submitForm(this,
>> "addroom")".
>> 
>> BTW, your use case is actually a styling of type "link" for the action
>> widget. I just added it to the CForms styling stylesheets, meaning with
>> the updated forms-field-styling.xsl you can now write:
>> 
>> <fd:repeater-action id="addroom" ....>
>>   <fd:label>Add a room</fd:label>
>> </fd:repeater-action>
>> 
>> and
>> 
>> <ft:widget id="addroom">
>>   <fi:styling type="link"/>
>> </ft:widget>
>> 
>> Enjoy,
>> Sylvain
>> 
> Thx Sylvain, That's reativity :) Thx
> Regards
> Tibor



Re: Repeater addRow action button to link??

Posted by oceatoon <t....@systheo.com>.
Sylvain Wallez wrote:

> oceatoon wrote:
> 
>>Hi everyone
>>
>>I tried posting this too the user list but got no answer hope I'll be
>>luckier in dev :)
>>
>>in our website, I tried to make a link that launches the addrow action
>>instead of the usual submit type button launching on my repeater,
>>but I can't get it to launch the action??
>>
>>this is what is originaly done
>><input name="addroom" type="submit" id="addroom" value="Add a Room" />
>>
>>and I would want
>><a href="javascript:document.forms[0].submit();" id="addroom">Add Room</a>
>>but this has a complete submit action,  and not just addrow submit ???
>>
>> Following the event handler docs, is it possible to connect my link to
>> the
>>list of event listenners or actions define for the addrow? in my case
>>addroom ?
>>  
>>
> 
> Yes. Please have a look at how is implemented "submit-on-change" in
> forms-field-styling.xsl: you have to call "forms_submitForm(this,
> "addroom")".
> 
> BTW, your use case is actually a styling of type "link" for the action
> widget. I just added it to the CForms styling stylesheets, meaning with
> the updated forms-field-styling.xsl you can now write:
> 
> <fd:repeater-action id="addroom" ....>
>   <fd:label>Add a room</fd:label>
> </fd:repeater-action>
> 
> and
> 
> <ft:widget id="addroom">
>   <fi:styling type="link"/>
> </ft:widget>
> 
> Enjoy,
> Sylvain
> 
Thx Sylvain, That's reativity :) Thx
Regards
Tibor


Re: Repeater addRow action button to link??

Posted by Sylvain Wallez <sy...@apache.org>.
oceatoon wrote:

>Hi everyone
>
>I tried posting this too the user list but got no answer hope I'll be
>luckier in dev :) 
>
>in our website, I tried to make a link that launches the addrow action
>instead of the usual submit type button launching on my repeater,
>but I can't get it to launch the action?? 
>
>this is what is originaly done
><input name="addroom" type="submit" id="addroom" value="Add a Room" />
>
>and I would want
><a href="javascript:document.forms[0].submit();" id="addroom">Add Room</a>
>but this has a complete submit action,  and not just addrow submit ???
>
> Following the event handler docs, is it possible to connect my link to the
>list of event listenners or actions define for the addrow? in my case
>addroom ?
>  
>

Yes. Please have a look at how is implemented "submit-on-change" in 
forms-field-styling.xsl: you have to call "forms_submitForm(this, 
"addroom")".

BTW, your use case is actually a styling of type "link" for the action 
widget. I just added it to the CForms styling stylesheets, meaning with 
the updated forms-field-styling.xsl you can now write:

<fd:repeater-action id="addroom" ....>
  <fd:label>Add a room</fd:label>
</fd:repeater-action>

and

<ft:widget id="addroom">
  <fi:styling type="link"/>
</ft:widget>

Enjoy,
Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }