Am Wednesday, 04. June 2003 18:24, schrieb [EMAIL PROTECTED]:
> Hello.
>
> I'd like to use the ESQL taglib inside a PerForm validation subroutine,
> but it needs $document and the like.

The solution is simple: in the <xsp:structure> section, ESQL behaves exactly 
as in any other place:

>
> Example:
>
> <xsp:logic>
> sub validate_domain {
>         my ($ctxt, $value) = @_;
>
>         # Strip leading and trailing whitespace.
>         $value =~ s/^\s*//;
>         $value =~ s/\s*$//;
>
>         # The domain must not be null.
>         die 'The domain can not be blank, or all spaces' unless $value;
>
>         # The domain must be the correct length and contain only valid
> characters. $value =~ m/^[0-9a-zA-Z.]$/ || die 'The userid can contain only
> letters, digits, and the period (".") character';
>
>         # The domain must exist in the database.
>         <sql:connection>
>                 <sql:driver>mysql</sql:driver>
>                 <sql:dburl>dbname=<xsp:expr>$db_name</xsp:expr></sql:dburl>
>                 <sql:username><xsp:expr>$db_user</xsp:expr></sql:username>
>                 <sql:password><xsp:expr>$db_pass</xsp:expr></sql:password>
>                 <sql:execute-query>
>                         <sql:query>
>                                 SELECT  *
>                                 WHERE   domain =
> '<xsp:expr>$value</xsp:expr>' </sql:query>

>                         <sql:no-results>
This has to be: <sql:no-results><xsp:logic>

>                                 # Maintain with the uid validator.
>                                 die "The domain does not exist";

>                         </sql:no-results>
And </xsp:logic></sql:no-results>...

>                 </sql:execute-query>
>         </sql:connection>
> }
> </xsp:logic>


-- 
CU
   Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to