<< | Index | >>
error handling by user input (POST/GET)
SBSM::State in path/to/sbsm/lib/sbsm/state.rb
def error?
!@errors.empty?
end
ODDB::State::Global in src/state/global.rb
def user_input(keys=[], mandatory=[])
keys = [keys] unless keys.is_a?(Array)
mandatory = [mandatory] unless mandatory.is_a?(Array)
hash = @session.user_input(*keys)
hash ||= {}
unless(hash.is_a?(Hash))
hash = {keys.first => hash}
end
keys.each { |key|
carryval = nil
value = hash[key]
if(value.is_a? RuntimeError)
carryval = value.value
@errors.store(key, hash.delete(key))
elsif(mandatory.include?(key) && mandatory_violation(value))
error = create_error('e_missing_' << key.to_s, key, value)
@errors.store(key, error)
hash.delete(key)
else
carryval = value
end
if(@model.is_a? Persistence::CreateItem)
@model.carry(key, carryval)
end
}
hash
end
We can validate array format name
z.B.
Validator in src/util/validator.rb
STRING = [ ... :names, ... ] ... NUMERIC = [ ... index, ... ]
SBSM State#user_input -> Session#user_input
@@input_ptrn = /([^\[]+)\[([^\]]+)\]/
def user_input(*keys)
if(keys.size == 1)
index = nil
key = keys.first.to_s
if match = @@input_ptrn.match(key)
key = match[1]
index = match[2]
end
key_sym = key.to_sym
valid = @valid_input[key_sym]
if(index && valid.respond_to?(:[]))
valid[index]
else
valid
end
else
keys.inject({}) { |inj, key|
inj.store(key, user_input(key))
inj
}
end
end
use update method with pointer. link this
# store new (update)
ch.oddb> update(registration('31706').fachinfo.pointer, {:links => [FachinfoLink.new]}, :admin)
-> #<ODDB::FachinfoDocument2001:0xe1a1fcc>
ch.oddb> registration('31706').fachinfo.links
-> [#<ODDB::FachinfoLink:0xe19a970 @name="", @url="">]
# after updating by browser
ch.oddb> registration('31706').fachinfo.links
-> [#<ODDB::FachinfoLink:0xc275824 @name="test", @url="http://example.com">]
ch.oddb>
HtmlGrid::List has these sort options.
SORT_DEFAULT = :to_s
SORT_HEADER = true
SORT_REVERSE = false
View classes of Fachinfo
* Fachinfo2001
* FiChapterChooserLink < HtmlGrid::Link
* FiChapterChooser < HtmlGrid::Composite
* include View::AdditionalInformation
* include View::Print
* Container of FiChapterChooserLink
* FachinfoPhotoView < HtmlGrid::Div
* as virtual photos chapter (FachinfoDocument object does not have photo)
* FachinfoInnerComposite < HtmlGrid::DivComposite
* Container of View::Chapter and FachinfoPhotoView
* FachinfoPreViewComposite < HtmlGrid::Composite
* View class for VorShau after uploading fachinfo word file
* Container of FachinfoInnerComposite
* FachinfoPrintInnerComposite < FachinfoInnerComposite
* no used ?
* Container of View::PrintChapter
* FachinfoPrintComposite < HtmlGrid::DivComposite
* View class for Print action
* Container of FachinfoInnerComposite
* FachinfoComposite < FachinfoPreviewComposite
* Container of FiChooserChapter, FachinfoInnerComposite, View::Chapter, usw.
* CompanyFachinfoPrintComposite < FachinfoPrintComposite
* RootFachinfoComposite < FachinfoComposite
* Fachinfo < PrivateTemplate
* Container of FachinfoComposite
* FachinfoPreview < PrivateTemplate
* Container of FachinfoPreviewComposite
* FachinfoPrint < PrivateTemplate
* Container of FachinfoPrintComposte
* CompanyFachinfoPrint < FachinfoPrint
* RootFachinfo < PrivateTemplate
* Container of RootFachinfoComposite
* EditFiChapterChooser < FiChapterChooser
* FiChapterChooser for admin user
* RootFachinfoComposite < FachinfoComposite
* Container of EditFiChapterChooser
* Container of View::EditLinkForm, View::EditChapterForm