You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Matt Sergeant <ma...@sergeant.org> on 2001/06/27 16:20:30 UTC

ANNOUNCE: AxKit::XSP::PerForm (fwd)

I thought this might be of interest to some of the people who are fiddling
with widgets at the moment ;-)

-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\

---------- Forwarded message ----------
Date: Wed, 27 Jun 2001 15:19:51 +0100 (BST)
From: Matt Sergeant <ma...@sergeant.org>
To: AxKit Users Mailing List <ax...@axkit.org>
Subject: ANNOUNCE: AxKit::XSP::PerForm

This module is a "magic" forms library for building complex web
applications. No docs yet, but here's an example. You also need to apply a
stylesheet to the results to get HTML or WML or whatever you're after for
your form. There's a HTML stylesheet in the stylesheets/ directory. We
suggest you add it to the stylesheet you're using for your site using
<xsl:import/>.

The Example (this is a real example for a project I'm working on):

<?xml version="1.0"?>
<xsp:page
    xmlns:xsp="http://apache.org/xsp/core/v1"
    xmlns:web="http://axkit.org/NS/xsp/webutils/v1"
    xmlns:f="http://axkit.org/NS/xsp/perform/v1"
    language="perl"
    indent-result="yes"
>
<xsp:structure>
  <xsp:import>Time::Object</xsp:import>
  <xsp:import>Time::Seconds</xsp:import>
</xsp:structure>

<xsp:logic><![CDATA[

sub load_expires_year {
    my ($ctxt, $selected) = @_;
    return ($selected || $ctxt->{expires}->year),
        map { $_ => $_ } (localtime->year .. localtime->year + 10);
}

sub load_expires_month {
    my ($ctxt, $selected) = @_;
    return ($selected || $ctxt->{expires}->mon),
        map { $_ => $_ } (1 .. 12);
}

sub load_expires_day {
    my ($ctxt, $selected) = @_;
    return ($selected || $ctxt->{expires}->day_of_month),
        map { $_ => $_ } (1 .. 31);
}

sub validate_title {
    my ($ctxt, $new) = @_;
}

sub start_form_create {
    my $ctxt = shift;
    my $expires = localtime;
    $expires += (20 * ONE_DAY);
    $ctxt->{expires} = $expires;
}

sub end_form_create {
}

sub submit_save {
  # save form values
  ...
  # return URL to redirect to after save
  return "/";
}

sub cancel_cancel {
  # return a URL to redirect to
  return "/";
}

</xsp:logic>

<html>


<head>
<title>Create Announcement</title>
</head>

<body>

<h1>Create Announcement</h1>

<f:form name="create">

Title: <f:textfield type="text" name="title" width="30" maxlength="255" />
<br />
Link: <f:textfield type="text" name="link" width="30" maxlength="255" />
<br />
Expires:
<f:single-select name="expires_year"/>
<f:single-select name="expires_month"/>
<f:single-select name="expires_day"/>

<br />

<f:submit name="save" value="Create"/>
<f:cancel name="cancel" value="Cancel"/>

</f:form>

</body>
</html>
</xsp:page>

-- 
<Matt/>

    /||    ** Founder and CTO  **  **   http://axkit.com/     **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // ** mod_perl news and resources: http://take23.org  **
     \\//
     //\\
    //  \\


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