-------------------------------------------------------------------------------- -- Title: LWFormText.lua -- Description: Like a square peg in a round hole -- Author: Raphaël Szwarc http://alt.textdrive.com/lua/ -- Creation Date: February 1, 2005 -- Legal: Copyright (C) 2005 Raphaël Szwarc -------------------------------------------------------------------------------- -- import dependencies local LWFormInput = require( "LWFormInput" ) local LWString = require( "LWString" ) local LWStyle = require( "LWStyle" ) local LUList = require( "LUList" ) -- define the class local super = LWFormInput local self = super() function self:handleComponentKeyWithValue( aComponent, aKey, aValue ) local aDefaultKey = aKey:gsub( "%._$", "" ) local aMethod = self:componentMethodWithKey( aComponent, aDefaultKey ) if aMethod ~= nil then local someParameters = aComponent:context():request():parameters() if aKey == aDefaultKey and someParameters:hasKey( aDefaultKey ) == true or aKey ~= aDefaultKey and someParameters:hasKey( aDefaultKey ) == false then if aKey ~= aDefaultKey then aValue = nil end aComponent:invoke( aMethod, aValue ) end end end function self:prefix() return "text." end function self:type() return "text" end function self:maxLength() return self:bindings():get( "maxLength" ) or 255 end function self:size() return self:bindings():get( "size" ) or 16 end function self:value() local aValue = self:bindings():get( "value" ) if aValue ~= nil then aValue = LWString:encode( aValue ) end return aValue or "" end -- method for string representation function self:toString() local aBuffer = LUList() local aStyle = LWStyle:styleWithComponent( self ) aBuffer:add( "" ) aBuffer:add( self:hidden() ) return aBuffer:join( "" ) end return self