Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: Embperl

Problems customizing selected form elements output

 

 

ModPerl embperl RSS feed   Index | Next | Previous | View Threaded


realmerx at gmail

Sep 6, 2007, 5:25 PM

Post #1 of 6 (1184 views)
Permalink
Problems customizing selected form elements output

Hello,

Using embperl 2.2.0 I would like to use embperl feature that allows
automatic input values filling and checkbox, option and radio button
checking when correct values are specified in %fdat. The problem is that for
example for selected input type="checkbox" html generated by Embperl is

<input type="checkbox" value="1" checked>

This is a problem because I use EMBPERL_RECIPE EmbperlXSLT and pass
everything through XSLT. But XSLT expects valid XML as input so it fails to
parse the invalid checked attribute.

I would like embperl to generate html code like

<input type="checkbox" value="1" checked="checked" />

I also tried EMBPERL_OUTPUT_MODE 1 but checked input was still generated as
checked instead of checked="checked".

I tried looking/modifying Embperl::Syntax with no success.
Also modifying epcmd.c (is that file even used - could not find any
references in make log when compiling) and finally epcmd2.c.
But I could not achieve what I need. I could of course use EmbperlBlocks
syntax and prevent all HTML processing but I like %fdat "magic" too much.

What would I have to change to modify this behaviour? Or maybe there are
patches in CVS/SVN?

All the best,
Villu


realmerx at gmail

Sep 7, 2007, 12:45 PM

Post #2 of 6 (1113 views)
Permalink
Re: Problems customizing selected form elements output [In reply to]

Hi again,

Well I have partially achieved what I want. I took a good look on the
Embperl::Syntax::* code and documentation again and figured out that I can
do what I want by using _ep_sa (XML::Embperl::DOM::Element::iSetAttribut in
DOM.xs) function instead of Embperl::Cmd::InputCheck.

In case anyone is interested I give here original and replaced code from
EmbperlHTML.pm (actually I made a new syntax to prevent overwriting core).

original:

$self -> AddTag ('input', ['type', 'name', 'value'], ['src'], ['checked'],
{
perlcode =>
[
'Embperl::Cmd::InputCheck (%$n%, %&*\'name%,
%&*\'value%, %&\'checked%) ; %&=-type:radio|checkbox% ',
#'_ep_sa(%$n%, \'checked\', \'checked\')
if($fdat{%&*\'name%}); %&=-type:radio|checkbox% ',
'$idat{%&*\'name%}=$fdat{%&*\'name%} ; _ep_sa(%$n%,
\'value\', exists ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\') ;
%&!-value%',
'$idat{%&*\'name%}=%&*\'value% ; ',
]
}) ;

replaced:

$self -> AddTag ('input', ['type', 'name', 'value', 'checked'], ['src'],
undef,
{
perlcode =>
[
#'Embperl::Cmd::InputCheck (%$n%, %&*\'name%,
%&*\'value%, %&\'checked%) ; %&=-type:radio|checkbox% ',
'_ep_sa(%$n%, \'checked\', \'checked\')
if($fdat{%&*\'name%}); %&=-type:radio|checkbox% ',
'$idat{%&*\'name%}=$fdat{%&*\'name%} ; _ep_sa(%$n%,
\'value\', exists ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\') ;
%&!-value%',
'$idat{%&*\'name%}=%&*\'value% ; ',
]
}) ;



But now I have another problem.

When I write my html "xhtml" way (I need to do this because I want to send
embperl output to XSLT processor) then checked or checked="checked" in
replaced EmbperlHTML syntax is inserted at the wrong place

For example

<input type="checkbox" name="c1" value="v1" />

now when I use %fdat magic to check the checkbox embperl generates:

old syntax:
<input type="checkbox" name="c1" value="v1" / checked>
my new modified syntax:
<input type="checkbox" name="c1" value="v1" / checked="checked">

but I need it to generate:

old syntax:
<input type="checkbox" name="c1" value="v1" checked />
my new modified syntax:
<input type="checkbox" name="c1" value="v1" checked="checked" />

So the "checked" is inserted after slash "/", it should be inserted before
it.

What would I have to change (Embperl::Syntax ?) or something else to insert
slash in correct place?

With kind regards,
Villu


richter at ecos

Sep 29, 2007, 5:14 AM

Post #3 of 6 (1052 views)
Permalink
RE: Re: Problems customizing selected form elements output [In reply to]

Hi,

Please try to use the just uploaded Embperl 2.3.0 and set output mode 1
(xml). This should do the trick without the need of your custom syntax

Gerald


------------------------------------------------------------------------
Besuchen Sie unseren Messestand auf der SYSTEMS vom 23. - 26.10. in
München, Halle B3, Stand 425 www.ecos.de/messen-events/systems-2007.html
------------------------------------------------------------------------
Gerald Richter ECOS electronic communication services GmbH
******************* SECURING YOUR NETWORK ********************

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter[at]ecos.de Voice: +49 6133 939-122
WWW: http://www.ecos.de Fax: +49 6133 939-333

Sitz der Gesellschaft: Dienheim; AG Mainz HRB 6889; GF: W.Heck,G.Richter
------------------------------------------------------------------------



> -----Original Message-----
> From: Villu Roogna [mailto:realmerx[at]gmail.com]
> Sent: Friday, September 07, 2007 9:45 PM
> To: embperl[at]perl.apache.org
> Subject: Re: Problems customizing selected form elements output
>
> Hi again,
>
> Well I have partially achieved what I want. I took a good
> look on the Embperl::Syntax::* code and documentation again
> and figured out that I can do what I want by using _ep_sa
> (XML::Embperl::DOM::Element::iSetAttribut in DOM.xs) function
> instead of Embperl::Cmd::InputCheck.
>
> In case anyone is interested I give here original and
> replaced code from EmbperlHTML.pm (actually I made a new
> syntax to prevent overwriting core).
>
> original:
>
> $self -> AddTag ('input', ['type', 'name', 'value'], ['src'],
> ['checked'],
> {
> perlcode =>
> [
> 'Embperl::Cmd::InputCheck (%$n%,
> %&*\'name%, %&*\'value%, %&\'checked%) ; %&=-type:radio|checkbox% ',
> #'_ep_sa(%$n%, \'checked\', \'checked\')
> if($fdat{%&*\'name%}); %&=-type:radio|checkbox% ',
> '$idat{%&*\'name%}=$fdat{%&*\'name%} ;
> _ep_sa(%$n%, \'value\', exists
> ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\') ; %&!-value%',
> '$idat{%&*\'name%}=%&*\'value% ; ',
> ]
> }) ;
>
> replaced:
>
> $self -> AddTag ('input', ['type', 'name', 'value',
> 'checked'], ['src'], undef,
> {
> perlcode =>
> [
> #'Embperl::Cmd::InputCheck (%$n%,
> %&*\'name%, %&*\'value%, %&\'checked%) ; %&=-type:radio|checkbox% ',
> '_ep_sa(%$n%, \'checked\', \'checked\')
> if($fdat{%&*\'name%}); %&=-type:radio|checkbox% ',
> '$idat{%&*\'name%}=$fdat{%&*\'name%} ;
> _ep_sa(%$n%, \'value\', exists
> ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\') ; %&!-value%',
> '$idat{%&*\'name%}=%&*\'value% ; ',
> ]
> }) ;
>
>
>
> But now I have another problem.
>
> When I write my html "xhtml" way (I need to do this because I
> want to send embperl output to XSLT processor) then checked
> or checked="checked" in replaced EmbperlHTML syntax is
> inserted at the wrong place
>
> For example
>
> <input type="checkbox" name="c1" value="v1" />
>
> now when I use %fdat magic to check the checkbox embperl generates:
>
> old syntax:
> <input type="checkbox" name="c1" value="v1" / checked> my new
> modified syntax:
> <input type="checkbox" name="c1" value="v1" / checked="checked">
>
> but I need it to generate:
>
> old syntax:
> <input type="checkbox" name="c1" value="v1" checked /> my new
> modified syntax:
> <input type="checkbox" name="c1" value="v1" checked="checked" />
>
> So the "checked" is inserted after slash "/", it should be
> inserted before it.
>
> What would I have to change (Embperl::Syntax ?) or something
> else to insert slash in correct place?
>
> With kind regards,
> Villu
>
>
>

** Virus checked by BB-5000 Mailfilter **

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe[at]perl.apache.org
For additional commands, e-mail: embperl-help[at]perl.apache.org


realmerx at gmail

Oct 10, 2007, 1:03 AM

Post #4 of 6 (975 views)
Permalink
Re: Re: Problems customizing selected form elements output [In reply to]

Thank you very much. Will be trying it as soon as I get the time.

Could you tell me which files are responsible for the generation of the
(x)html. Is it all in Embperl::Syntax::* or does some of the logic is also
in *.c files.

All the best,
Villu


richter at ecos

Oct 10, 2007, 5:38 AM

Post #5 of 6 (970 views)
Permalink
RE: Re: Re: Problems customizing selected form elements output [In reply to]

>
> Thank you very much. Will be trying it as soon as I get the time.
>
> Could you tell me which files are responsible for the
> generation of the (x)html. Is it all in Embperl::Syntax::* or
> does some of the logic is also in *.c files.
>

The difference between html and xhtml is mostly in the C file. In this
case it's in epcmd2.c .

Gerald


** Virus checked by BB-5000 Mailfilter **

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe[at]perl.apache.org
For additional commands, e-mail: embperl-help[at]perl.apache.org


realmerx at gmail

Oct 10, 2007, 7:34 AM

Post #6 of 6 (980 views)
Permalink
Re: Re: Re: Problems customizing selected form elements output [In reply to]

Thank you for the information.

VIllu

On 10/10/07, Gerald Richter - ECOS GmbH <richter[at]ecos.de> wrote:
>
> >
> > Thank you very much. Will be trying it as soon as I get the time.
> >
> > Could you tell me which files are responsible for the
> > generation of the (x)html. Is it all in Embperl::Syntax::* or
> > does some of the logic is also in *.c files.
> >
>
> The difference between html and xhtml is mostly in the C file. In this
> case it's in epcmd2.c .
>
> Gerald
>
>
> ** Virus checked by BB-5000 Mailfilter **
>

ModPerl embperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.