Is there a TEXTAREA with a verification function in TapeSTRY?

xiaoxiao2021-03-06  42

I also forgot where I found it as follows: Three files: ValidTextArea.java:

Java code:

Package COM.

Tomxp.

Web.

Components.

Valid;

Import org.

Apache.

Tapestry.

ApplicationRuntimeException;

Import org.

Apache.

Tapestry.

IFORM;

Import org.

Apache.

Tapestry.

IMarkupwriter;

Import org.

Apache.

Tapestry.

IREQuestCYCLE;

Import org.

Apache.

Tapestry.

Tapestry;

Import org.

Apache.

Tapestry.

Form.

TEXTAREA;

Import org.

Apache.

Tapestry.

Valid.

IvalidationDelegate;

Import org.

Apache.

Tapestry.

Valid.

Ivalidator;

Import org.

Apache.

Tapestry.

Valid.

ValidatorException;

/ ** * @Author peter butler * /

public

Abstract

Class ValidTextArea

Extends

Textarea

{

WritererRordecoator myWriter =

New WritererRordecorator

(this

);

Public ValidTextArea

(

)

{

Super

(

);

}

public

Abstract IvaliDator getValidator

(

);

public

Abstract

String getDisplayName

(

);

protected

Void rendercomponent

(ImarkupWriter Writer, Irequestcycle Cycle

)

{

IFORM FORM = Getform

(Cycle

);

IvalidationdeLegate delegate = form.

Getdelegate

(

);

IF

(Delegate ==

NULL

)

Throw

New ApplicationRuntimeException

Tapestry.

Format

"" ValidTextarea.

No-delegate, getExtendedidID

(

Getform

(

).

GetExtendedidID

(

)

), THIS,

NULL,

NULL

);

Ivalidator validator = getValidator

(

);

IF

(Validator ==

NULL

)

Throw TapeStry.

CreateRequidParameterException

(this, "validator"

);

Boolean rendering =! cycle.

Isrewinding

(

);

ImarkupWriter Superwriter;

IF

(Rendering)

)

{

Delegate.

Writeprefix

(Writer, Cycle, This, Validator

);

MYWRITER.

init

(Writer, Delegate, Validator, Cycle

);

Superwriter = mywriter;

}

Else

{

Superwriter = Writer;}

SUPER.

Rendercomponent

(SuperWriter, Cycle

);

String name = getName

(

);

IF

(! RENDERING &&! Isdisabled

(

)

)

{

String value = cycle.

GetRequestContext

(

).

GetParameter

(Name)

);

UpdateValue

(Value

);

}

IF

(Rendering)

)

{

Delegate.

Writesuffix

(Writer, Cycle, This, Validator

);

MYWRITER.

Clear

(

);

}

}

protected

Void UpdateValue

(

String Value

)

{

Object ObjectValue =

NULL;

IvalidationdeLegate delegate = getform

(

).

Getdelegate

(

);

Delegate.

RecordfieldInputValue

(Value

);

Try

{

ObjectValue = GetValidator

(

).

TOOBJECT

(this, Value

);

}

Catch

(ValidatorException EX

)

{

Delegate.

Record

(EX

);

Return;

}

SetValue

(

(

String

) ObjectValue

);

}

}

ValidTextArea.jwc

Java code:

1.

0 "encoding =" UTF-

8 "?>

DOCTYPE Component-Specification

PUBLIC "-

// Apache Software Foundation // TapeStry Specification 3.0 // en "

"http:

//jakarta.apache.org/tapestry/dtd/tapestry_3_0.dtd ">

//spindle.sourceforge.net ->

Class = "COM.

Tomxp.

Web.

Components.

Valid.

ValidTextArea "allow-body =" no ">

A Multi-Line Valid Text Area.

Converts Value to A String and Parses Strings Back Into Object Values.

Name Used by FieldLabel and when Generating Validation Error Messages.

Java code:

Package COM.

Tomxp.

Web.

Components.

Valid;

Import org.

Apache.

Tapestry.

IMarkupwriter;

Import org.

Apache.

Tapestry.

IREQuestCYCLE;

Import org.

Apache.

Tapestry.

Form.

IFORMComponent;

Import org.

Apache.

Tapestry.

Valid.

IvalidationDelegate;

Import org.

Apache.

Tapestry.

Valid.

Ivalidator;

/ ** * @Author peter butler * /

public

Class WritererRordecorator

Implements IMARKUPWRITER

{

PRIVATE IMARKUPWRITER ACTUAL;

Private ivalidationdelegate delegate;

Private ivalidator validator;

Private IREQUESTCYCLE CYCLE;

Private iFormComponent Field;

Public WritererRordecorator

(IFormComponent Field

)

{

THIS.

Field = field;

}

public

Voidin

(ImarkupWriter Actual, IvalidationDelegate Delegate, Ivalidator Validator, IREQuestCYCLE CYCLE

)

{

THIS.

Actual = actual;

THIS.

Delegate = delegate;

THIS.

Validator = validator;

THIS.

CYCLE = cycle;

}

public

Void Clear

(

)

{

THIS.

Actual = NULL;

THIS.

Delegate =

NULL;

THIS.

Validator =

NULL;

THIS.

CYCLE =

NULL;

}

public

Void Attribute

(

String Name,

Int Value

)

{

Actual.

Attribute

(Name, Value

);

}

public

Void Attribute

(

String Name,

Boolean Value

)

{

Actual.

Attribute

(Name, Value

);

}

public

Void Attribute

(

String Name,

String Value

)

{

Actual.

Attribute

(Name, Value

);

}

public

Void AttributeRaw

(

String Name,

String Value

)

{

Actual.

AttributeRaw

(Name, Value

);

}

public

Void Begin

(

String name

)

{

Actual.

Begin

(Name)

);

Validator.

RenderValidatorControl

(Field, this, cycle

);

Delegate.

WriteaTributes

(this, Cycle, Field, Validator

);

}

public

Void Beginempty

(

String name

)

{

Actual.

Beginempty

(Name)

);

Validator.

RenderValidatorControl

(Field, this, cycle

);

Delegate.

WriteaTributes

(this, Cycle, Field, Validator

);

}

public

Boolean Checkerror

(

)

{

Return Actual.

Checkerror

(

);

}

public

Void Close

(

)

{

Actual.

Close

(

);

}

public

Void ClosetAg

(

)

{

Actual.

Closetag

(

);

}

public

Void Comment

(

String Value

)

{

Actual.

Comment

(Value

);

}

public

Void end

(

)

{

Actual.

end

(

);

}

public

Void end

(

String name

)

{

Actual.

end

(Name)

);

}

public

Void Flush

(

)

{

Actual.

Flush

(

);

}

Public IMARKUPWRITER GETNESTEDWRITER

(

)

{

Return Actual.

GetnestedWriter

(

);

}

public

Void Print

(char)

[

] DATA,

Int offset,

INT Length

)

{

Actual.

Print

(Data, Offset, Length

);

}

public

Void Print

(Char Value)

)

{

Actual.

Print

(Value

);

}

public

Void Print

(

Int Value

)

{

Actual.

Print

(Value

);

}

public

Void Print

(

String value)

{

Actual.

Print

(Value

);

}

public

Void Println

(

)

{

Actual.

PRINTLN

(

);

}

public

Void Printraw

(char)

[

] buffer,

Int offset,

INT Length

)

{

Actual.

PRINTRAW

(Buffer, Offset, Length

);

}

public

Void Printraw

(

String Value

)

{

Actual.

PRINTRAW

(Value

);

}

public

String getContentType

(

)

{

Return Actual.

GetContentType

(

);

}

}

For TextArea's length verification, only write components yourself. Especially when the Tapestry's FieldLabel Validator is already using Tapestry, if only simply written JS is written in HTML, there will be a JavaScript integration that cannot be dynamically generated by Tapestry. . . I saw the code of Ewaves stickers, and I didn't seem to posted. Script files. I have written my own components, although it is totally different from the code, but .script file can be universal, it can automatically generate dynamic JavaScript.

Java code:

1.

0 "Encoding =" GBK "?>

Script, V

1.

5

2004 /

03 /

09

18:

twenty three:

50 HLSHIP EXP $ ->

DOCTYPE SCRIPT

Public

"

// Apache Software Foundation // TapeStry Script Specification 3.0 // en "

"http:

//jakarta.apache.org/tapestry/dtd/script_3_0.dtd ">