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 feature -- Access
default_value: detachable READABLE_STRING_GENERAL default_value: detachable READABLE_STRING_32
rows: INTEGER rows: INTEGER
@@ -54,9 +54,13 @@ feature -- Element change
end end
end end
set_default_value (v: like default_value) set_default_value (v: detachable READABLE_STRING_GENERAL)
do do
default_value := v if v = Void then
default_value := Void
else
default_value := v.as_string_32
end
end end
feature -- Conversion feature -- Conversion

View File

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

View File

@@ -48,7 +48,9 @@ feature -- Access
item (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE item (a_name: READABLE_STRING_GENERAL): detachable WSF_VALUE
do 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 end
string_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32 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 (a_val: INTEGER)
-- Set `max' with `a_val'. -- Set `max' with `a_val'.
do do
set_max_string(a_val.out) set_max_string (a_val.out)
ensure ensure
max_set: attached max as l_max implies l_max.same_string (a_val.out) max_set: attached max as l_max implies l_max.same_string (a_val.out)
end end
@@ -94,7 +94,6 @@ feature -- Element Change
step_set: attached step as l_step implies l_step.same_string_general (a_val) step_set: attached step as l_step implies l_step.same_string_general (a_val)
end end
feature {NONE} -- Conversion feature {NONE} -- Conversion
append_numeric_input_attributes_to (a_target: STRING) append_numeric_input_attributes_to (a_target: STRING)
@@ -103,7 +102,7 @@ feature {NONE} -- Conversion
--min --min
if attached min as l_min then if attached min as l_min then
a_target.append (" min=%"") a_target.append (" min=%"")
a_target.append(l_min) a_target.append (l_min)
a_target.append_character ('%"') a_target.append_character ('%"')
end end

View File

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

View File

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

View File

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

View File

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