Made interface of wsf forms and widgets a bit more flexible by accepting READABLE_STRING_GENERAL.

This commit is contained in:
Jocelyn Fiat
2017-10-17 14:34:50 +02:00
parent f1642a444a
commit edec837c4e
8 changed files with 78 additions and 42 deletions

View File

@@ -22,7 +22,7 @@ feature {NONE} -- Initialization
feature -- Access
default_value: detachable READABLE_STRING_GENERAL
default_value: detachable READABLE_STRING_32
rows: INTEGER
@@ -54,9 +54,13 @@ feature -- Element change
end
end
set_default_value (v: like default_value)
set_default_value (v: detachable READABLE_STRING_GENERAL)
do
default_value := v
if v = Void then
default_value := Void
else
default_value := v.as_string_32
end
end
feature -- Conversion

View File

@@ -1,8 +1,7 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
description : "Objects containing widget WSF_WIDGET objects, and add specific form support (notion of form fields)."
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_FORM_COMPOSITE

View File

@@ -48,7 +48,9 @@ feature -- Access
item (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
do
Result := items.item (a_name.as_string_8)
if a_name.is_valid_as_string_8 then
Result := items.item (a_name.to_string_8)
end
end
string_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32

View File

@@ -39,7 +39,7 @@ feature -- Element Change
set_max (a_val: INTEGER)
-- Set `max' with `a_val'.
do
set_max_string(a_val.out)
set_max_string (a_val.out)
ensure
max_set: attached max as l_max implies l_max.same_string (a_val.out)
end
@@ -94,7 +94,6 @@ feature -- Element Change
step_set: attached step as l_step implies l_step.same_string_general (a_val)
end
feature {NONE} -- Conversion
append_numeric_input_attributes_to (a_target: STRING)
@@ -103,7 +102,7 @@ feature {NONE} -- Conversion
--min
if attached min as l_min then
a_target.append (" min=%"")
a_target.append(l_min)
a_target.append (l_min)
a_target.append_character ('%"')
end

View File

@@ -19,7 +19,7 @@ feature {NONE} -- Initialization
name := a_name
end
make_with_text (a_name: like name; a_text: READABLE_STRING_32)
make_with_text (a_name: like name; a_text: READABLE_STRING_GENERAL)
do
make (a_name)
set_text_value (a_text)
@@ -44,7 +44,7 @@ feature -- Access
feature -- Element change
set_text_value (s: detachable READABLE_STRING_32)
set_text_value (s: detachable READABLE_STRING_GENERAL)
do
set_default_value (s)
end
@@ -73,9 +73,13 @@ feature -- Element change
end
end
set_default_value (v: like default_value)
set_default_value (v: detachable READABLE_STRING_GENERAL)
do
default_value := v
if v = Void then
default_value := Void
else
default_value := v.as_string_32
end
end
feature -- Conversion

View File

@@ -35,12 +35,17 @@ feature -- Access
feature -- Change element
set_placeholder (a_placeholder: READABLE_STRING_32)
set_placeholder (a_placeholder: detachable READABLE_STRING_GENERAL)
-- Set `placeholder' with `a_placeholder'.
do
placeholder := a_placeholder
if a_placeholder = Void then
placeholder := Void
else
placeholder := a_placeholder.as_string_32
end
ensure
placeholder_set: attached placeholder as l_placeholder implies l_placeholder = a_placeholder
placeholder_set: (a_placeholder = Void implies placeholder = Void)
or (a_placeholder /= Void implies (attached placeholder as l_placeholder and then a_placeholder.same_string (l_placeholder)))
end
enable_autofocus
@@ -91,16 +96,21 @@ feature -- Change element
required_flase: not required
end
set_pattern (a_pattern: READABLE_STRING_32)
set_pattern (a_pattern: READABLE_STRING_GENERAL)
-- Set `pattern' with `a_pattern'.
-- Example:[0-9][A-Z]{3}
-- Check HTML5 patterns site.
note
EIS: "name=HTML5 Patterns", "src=http://html5pattern.com/"
do
pattern := a_pattern
if a_pattern = Void then
pattern := Void
else
pattern := a_pattern.as_string_32
end
ensure
pattern_set: attached pattern as l_pattern implies l_pattern = a_pattern
pattern_set: (a_pattern = Void implies pattern = Void) or
a_pattern /= Void implies attached pattern as l_pattern and then a_pattern.same_string (l_pattern)
end

View File

@@ -43,7 +43,6 @@ feature -- Access
feature -- Element Change
set_formnovalidate
-- Set formnovalidate to True.
do
@@ -60,49 +59,69 @@ feature -- Element Change
formnovalidate_false: not formnovalidate
end
set_formaction (a_action: READABLE_STRING_GENERAL)
set_formaction (a_action: detachable READABLE_STRING_GENERAL)
-- Set `formaction' with `a_action'.
-- Example:<input type="submit" value="Submit" formaction="/users">
require
is_valid_as_string_8: a_action.is_valid_as_string_8
is_valid_as_string_8: a_action /= Void implies a_action.is_valid_as_string_8
do
formaction := a_action.to_string_8
if a_action = Void then
formaction := Void
else
formaction := a_action.to_string_8
end
ensure
formaction_set: attached formaction as l_action implies l_action = a_action
formaction_set: (a_action = Void implies formaction = Void)
or (a_action /= Void implies (attached formaction as l_action and then a_action.same_string (l_action)))
end
set_formenctype (a_enctype: READABLE_STRING_GENERAL)
set_formenctype (a_enctype: detachable READABLE_STRING_GENERAL)
-- Set `formenctype' with `a_enctype'.
-- Example: <input type="submit" value="Submit" formenctype="application/x-www-form-urlencoded">
require
is_valid_as_string_8: a_enctype.is_valid_as_string_8
is_valid_as_string_8: a_enctype /= Void implies a_enctype.is_valid_as_string_8
do
formenctype := a_enctype.to_string_8
if a_enctype = Void then
formenctype := Void
else
formenctype := a_enctype.to_string_8
end
ensure
formenctype_set: attached formenctype as l_enctype implies l_enctype = a_enctype
formenctype_set: (a_enctype = Void implies formenctype = Void)
or (a_enctype /= Void implies (attached formenctype as l_enctype and then a_enctype.same_string (l_enctype)))
end
set_formmethod (a_method: READABLE_STRING_GENERAL)
set_formmethod (a_method: detachable READABLE_STRING_GENERAL)
-- Set `formmethod' with `a_method'.
-- Example: <input type="submit" value="Submit" formmethod="POST">
--! require is_valid_method: [PUT, POST, DELETE, GET, ...]
require
is_valid_as_string_8: a_method.is_valid_as_string_8
is_valid_as_string_8: a_method /= Void implies a_method.is_valid_as_string_8
do
formmethod := a_method.to_string_8
if a_method = Void then
formmethod := Void
else
formmethod := a_method.to_string_8
end
ensure
formmethod_set: attached formmethod as l_method implies l_method = a_method
formmethod_set: (a_method = Void implies formmethod = Void)
or (a_method /= Void implies (attached formmethod as l_method and then a_method.same_string (l_method)))
end
set_formtarget (a_target: READABLE_STRING_GENERAL)
set_formtarget (a_target: detachable READABLE_STRING_GENERAL)
-- Set `formtarget' with `a_target'.
-- Example: <input type="submit" value="Submit" formtarget="_self">
require
is_valid_as_string_8: a_target.is_valid_as_string_8
is_valid_as_string_8: a_target /= Void implies a_target.is_valid_as_string_8
do
formtarget := a_target.to_string_8
if a_target = Void then
formtarget := Void
else
formtarget := a_target.to_string_8
end
ensure
formtarget_set: attached formtarget as l_target implies l_target = a_target
formtarget_set: (a_target = Void implies formtarget = Void)
or (a_target /= Void implies (attached formtarget as l_target and then a_target.same_string (l_target)))
end

View File

@@ -1,8 +1,7 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
description : "Objects containing WSF_WIDGET objects."
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_WIDGET_COMPOSITE