Documentation ¶
Index ¶
- Constants
- Variables
- func ControlConnectorParams() *maps.SliceMap
- func ConvertToBool(v interface{}) bool
- func DebugErrorPageTmpl(ctx context.Context, partialHtml string, err *Error, buf *bytes.Buffer)
- func DivTmpl(ctx context.Context, ctrl ControlI, h string, buf *bytes.Buffer)
- func ErrorTmpl(ctx context.Context, ctrl ControlI, h string, buf *bytes.Buffer)
- func GetAssetLocation(url string) string
- func GetAssetUrl(location string) string
- func GetBuffer() *bytes.Buffer
- func IsError(e error) bool
- func LabelTmpl(ctx context.Context, w *LabelWrapperType, ctrl ControlI, h string, ...)
- func PageTmpl(ctx context.Context, page *Page, buf *bytes.Buffer) (err error)
- func PutBuffer(buffer *bytes.Buffer)
- func PutContext(r *http.Request, cliArgs []string) *http.Request
- func Redirect(url string)
- func RegisterAssetDirectory(dir string, pattern string)
- func RegisterControlWrapper(name string, w WrapperI)
- func RegisterPage(path string, creationFunction FormCreationFunction, formId string)
- func RegisterTemplate(name string, t TemplateExecuter)
- func ReleaseErrorPageTmpl(ctx context.Context, partialHtml string, err *Error, buf *bytes.Buffer)
- func ServeAsset(w http.ResponseWriter, r *http.Request)
- func SetPageCache(c PageCacheI)
- func SetPageEncoder(e PageEncoderI)
- type ActionParams
- func (a *ActionParams) ActionValue(i interface{}) (ok bool, err error)
- func (a *ActionParams) ActionValueBool() bool
- func (a *ActionParams) ActionValueFloat() float64
- func (a *ActionParams) ActionValueInt() int
- func (a *ActionParams) ActionValueString() string
- func (a *ActionParams) ControlValue(i interface{}) (ok bool, err error)
- func (a *ActionParams) ControlValueBool() (ret bool)
- func (a *ActionParams) ControlValueFloat() float64
- func (a *ActionParams) ControlValueInt() int
- func (a *ActionParams) ControlValueString() string
- func (a *ActionParams) EventValue(i interface{}) (ok bool, err error)
- func (a *ActionParams) EventValueBool() bool
- func (a *ActionParams) EventValueFloat() float64
- func (a *ActionParams) EventValueInt() int
- func (a *ActionParams) EventValueString() string
- type AppContext
- type BufferPoolI
- type Context
- func (ctx *Context) CheckableValue(key string) (value interface{}, ok bool)
- func (ctx *Context) CheckableValues() map[string]interface{}
- func (ctx *Context) CustomControlValue(id string, key string) interface{}
- func (ctx *Context) FillApp(cliArgs []string)
- func (ctx *Context) FillHttp(r *http.Request) (err error)
- func (ctx *Context) FormValue(key string) (value string, ok bool)
- func (ctx *Context) FormValues(key string) (value []string, ok bool)
- func (ctx *Context) RequestMode() RequestMode
- func (c *Context) String() string
- type ContextI
- type Control
- func (c *Control) Action(ctx context.Context, a ActionParams)
- func (c *Control) ActionValue() interface{}
- func (c *Control) AddClass(class string) ControlI
- func (c *Control) AddRelatedRenderScript(id string, f string, params ...interface{})
- func (c *Control) AddRenderScript(f string, params ...interface{})
- func (c *Control) AddWrapperClass(class string) ControlI
- func (c *Control) Attribute(name string) string
- func (c *Control) Child(id string) ControlI
- func (c *Control) Children() []ControlI
- func (c *Control) Deserialize(d Decoder, p *Page) (err error)
- func (c *Control) Draw(ctx context.Context, buf *bytes.Buffer) (err error)
- func (c *Control) DrawAjax(ctx context.Context, response *Response) (err error)
- func (c *Control) DrawChildren(ctx context.Context, buf *bytes.Buffer) (err error)
- func (c *Control) DrawInnerHtml(ctx context.Context, buf *bytes.Buffer) (err error)
- func (c *Control) DrawTag(ctx context.Context) string
- func (c *Control) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error)
- func (c *Control) DrawText(ctx context.Context, buf *bytes.Buffer)
- func (c *Control) DrawingAttributes() *html.Attributes
- func (c *Control) ExecuteJqueryFunction(command string, params ...interface{})
- func (c *Control) GetActionScripts(r *Response)
- func (c *Control) GobDecode(data []byte) (err error)
- func (c *Control) GobEncode() (data []byte, err error)
- func (c *Control) HasAttribute(name string) bool
- func (c *Control) HasFor() bool
- func (c *Control) HasWrapper() bool
- func (c *Control) ID() string
- func (c *Control) Init(self ControlI, parent ControlI, id string)
- func (c *Control) Instructions() string
- func (c *Control) IsDisabled() bool
- func (c *Control) IsDisplayed() bool
- func (c *Control) IsRendering() bool
- func (c *Control) IsRequired() bool
- func (c *Control) IsVisible() bool
- func (c *Control) Label() string
- func (c *Control) MarshalJSON() (data []byte, err error)
- func (c *Control) MarshalState(m maps.Setter)
- func (c *Control) Off()
- func (c *Control) On(e EventI, actions ...action2.ActionI) EventI
- func (c *Control) Page() *Page
- func (c *Control) Parent() ControlI
- func (c *Control) ParentForm() FormI
- func (c *Control) PostRender(ctx context.Context, buf *bytes.Buffer) (err error)
- func (c *Control) PreRender(ctx context.Context, buf *bytes.Buffer) error
- func (c *Control) PrivateAction(ctx context.Context, a ActionParams)
- func (c *Control) PutCustomScript(ctx context.Context, response *Response)
- func (c *Control) Refresh()
- func (c *Control) Remove()
- func (c *Control) RemoveChild(id string)
- func (c *Control) RemoveChildren()
- func (c *Control) RemoveClass(class string) ControlI
- func (c *Control) RemoveClassesWithPrefix(prefix string)
- func (c *Control) RenderAutoControls(ctx context.Context, buf *bytes.Buffer) (err error)
- func (c *Control) Restore(self ControlI)
- func (c *Control) SaveState(ctx context.Context, saveIt bool)
- func (c *Control) Serialize(e Encoder) (err error)
- func (c *Control) SetActionValue(v interface{}) ControlI
- func (c *Control) SetAttribute(name string, val interface{}) ControlI
- func (c *Control) SetBlockParentValidation(block bool)
- func (c *Control) SetDataAttribute(name string, val interface{})
- func (c *Control) SetDisabled(d bool)
- func (c *Control) SetDisplay(d string)
- func (c *Control) SetEscapeText(e bool) ControlI
- func (c *Control) SetHasFor(v bool) ControlI
- func (c *Control) SetHeightStyle(h interface{}) ControlI
- func (c *Control) SetInstructions(i string) ControlI
- func (c *Control) SetIsRequired(r bool) ControlI
- func (c *Control) SetLabel(n string) ControlI
- func (c *Control) SetParent(newParent ControlI)
- func (c *Control) SetShouldAutoRender(r bool)
- func (c *Control) SetStyle(name string, value string) ControlI
- func (c *Control) SetStyles(s *html.Style)
- func (c *Control) SetText(t string) ControlI
- func (c *Control) SetValidationError(e string)
- func (c *Control) SetValidationTargets(controlIDs ...string)
- func (c *Control) SetValidationType(typ ValidationType)
- func (c *Control) SetVisible(v bool)
- func (c *Control) SetWidthStyle(w interface{}) ControlI
- func (c *Control) SetWillBeValidated(v bool)
- func (c *Control) SetWrapperAttribute(name string, val interface{}) ControlI
- func (c *Control) ShouldAutoRender() bool
- func (c *Control) T(message string, params ...interface{}) string
- func (c *Control) TPrintf(message string, params ...interface{}) string
- func (c *Control) Text() string
- func (c *Control) TextIsLabel() bool
- func (c *Control) UnmarshalJSON(data []byte) (err error)
- func (c *Control) UnmarshalState(m maps.Loader)
- func (c *Control) UpdateFormValues(ctx *Context)
- func (c *Control) Validate(ctx context.Context) bool
- func (c *Control) ValidationMessage() string
- func (c *Control) ValidationState() ValidationState
- func (c *Control) ValidationType(e EventI) ValidationType
- func (c *Control) WasRendered() bool
- func (c *Control) With(w WrapperI) ControlI
- func (c *Control) WrapEvent(eventName string, selector string, eventJs string) string
- func (c *Control) Wrapper() WrapperI
- func (c *Control) WrapperAttributes() *html.Attributes
- func (c *Control) ΩT(message string) string
- func (c *Control) ΩisSerializer(i ControlI) bool
- type ControlI
- type ControlLoc
- type ControlTemplateFunc
- type ControlWrapperFunc
- type DbError
- type Decoder
- type DivWrapperType
- func (w DivWrapperType) TypeName() string
- func (w DivWrapperType) ΩAjaxRender(ctx context.Context, response *Response, c ControlI)
- func (w DivWrapperType) ΩModifyDrawingAttributes(ctrl ControlI, a *html.Attributes)
- func (w DivWrapperType) ΩNewI() WrapperI
- func (w DivWrapperType) ΩSetValidationMessageChanged()
- func (w DivWrapperType) ΩSetValidationStateChanged()
- func (w DivWrapperType) ΩWrap(ctx context.Context, ctrl ControlI, html string, buf *bytes.Buffer)
- type DrawI
- type Encoder
- type Error
- type ErrorPageFuncType
- type ErrorWrapperType
- func (w *ErrorWrapperType) TypeName() string
- func (w *ErrorWrapperType) ΩAjaxRender(ctx context.Context, response *Response, c ControlI)
- func (w *ErrorWrapperType) ΩModifyDrawingAttributes(c ControlI, a *html.Attributes)
- func (w ErrorWrapperType) ΩNewI() WrapperI
- func (w *ErrorWrapperType) ΩSetValidationMessageChanged()
- func (w *ErrorWrapperType) ΩSetValidationStateChanged()
- func (w *ErrorWrapperType) ΩWrap(ctx context.Context, ctrl ControlI, html string, buf *bytes.Buffer)
- type Event
- func (e *Event) ActionValue(r interface{}) EventI
- func (e *Event) Blocking() EventI
- func (e *Event) Condition(javascript string) EventI
- func (e *Event) Delay(d int) EventI
- func (e *Event) GetActionValue() interface{}
- func (e *Event) GobDecode(data []byte) (err error)
- func (e *Event) GobEncode() (data []byte, err error)
- func (e *Event) PreventBubbling() EventI
- func (e *Event) PreventingDefault() EventI
- func (e *Event) Selector(s string) EventI
- func (e *Event) String() string
- func (e *Event) Terminating() EventI
- func (e *Event) Validate(v ValidationType) EventI
- func (e *Event) ValidationTargets(targets ...string) EventI
- type EventI
- type EventID
- type EventMap
- type FastPageCache
- type FormCreationFunction
- type FormI
- type FrameworkError
- type GobDeserializer
- type GobPageEncoder
- type GobSerializer
- type HttpContext
- type HttpError
- type LabelWrapperType
- func (w *LabelWrapperType) Copy() *LabelWrapperType
- func (w *LabelWrapperType) HasLabelAttributes() bool
- func (w *LabelWrapperType) LabelAttributes() *html.Attributes
- func (w *LabelWrapperType) TypeName() string
- func (w *LabelWrapperType) ΩModifyDrawingAttributes(c ControlI, a *html.Attributes)
- func (w *LabelWrapperType) ΩNewI() WrapperI
- func (w *LabelWrapperType) ΩWrap(ctx context.Context, ctrl ControlI, html string, buf *bytes.Buffer)
- type NoErr
- type Page
- func (p *Page) AddHtmlHeaderTag(t html.VoidTag)
- func (p *Page) ClearResponseHeaders()
- func (p *Page) Decode(d Decoder) (err error)
- func (p *Page) Draw(ctx context.Context, buf *bytes.Buffer) (err error)
- func (p *Page) DrawAjax(ctx context.Context, buf *bytes.Buffer) (err error)
- func (p *Page) DrawHeaderTags(ctx context.Context, buf *bytes.Buffer)
- func (p *Page) Encode(e Encoder) (err error)
- func (p *Page) Form() FormI
- func (p *Page) GenerateControlID(id string) string
- func (p *Page) GetControl(id string) ControlI
- func (p *Page) GobDecode(data []byte) (err error)
- func (p *Page) GobEncode() (data []byte, err error)
- func (p *Page) Init(path string)
- func (p *Page) LanguageCode() string
- func (p *Page) MarshalJSON() (data []byte, err error)
- func (p *Page) Path() string
- func (p *Page) PushRedraw()
- func (p *Page) Restore()
- func (p *Page) SetControlIdPrefix(prefix string) *Page
- func (p *Page) SetResponseHeader(key, value string)
- func (p *Page) SetTitle(title string)
- func (p *Page) StateID() string
- func (p *Page) Title() string
- func (p *Page) UnmarshalJSON(data []byte) (err error)
- type PageCacheI
- type PageDrawFunc
- type PageEncoderI
- type PageManager
- type PageManagerI
- type PageRenderStatus
- type Priority
- type RequestMode
- type Response
- func (r *Response) CloseWindow()
- func (r *Response) ExecuteControlCommand(controlID string, functionName string, args ...interface{})
- func (r *Response) ExecuteJavaScript(js string, priorities ...Priority)
- func (r *Response) ExecuteJsFunction(functionName string, args ...interface{})
- func (r *Response) ExecuteSelectorFunction(selector string, functionName string, args ...interface{})
- func (r *Response) JavaScript() (script string)
- func (r *Response) MarshalJSON() (buf []byte, err error)
- func (r *Response) SetControlAttribute(id string, attribute string, value string)
- func (r *Response) SetControlHtml(id string, html string)
- func (r *Response) SetControlValue(id string, value string)
- func (r *Response) SetLocation(newLocation string)
- type ResponseCommand
- type ResponseControl
- type Serializable
- type SerializedPageCache
- type StackFrame
- type TemplateExecuter
- type ValidationState
- type ValidationType
- type WrapperI
- type ΩFormBase
- func (f *ΩFormBase) AddFontAwesome()
- func (f *ΩFormBase) AddGoraddFiles()
- func (f *ΩFormBase) AddHeadTags()
- func (f *ΩFormBase) AddJQuery()
- func (f *ΩFormBase) AddJQueryUI()
- func (f *ΩFormBase) AddJavaScriptFile(path string, forceHeader bool, attributes *html.Attributes)
- func (f *ΩFormBase) AddMasterJavaScriptFile(url string, attributes []string, files []string)
- func (f *ΩFormBase) AddRelatedFiles()
- func (f *ΩFormBase) AddStyleSheetFile(path string, attributes *html.Attributes)
- func (f *ΩFormBase) ChangeLocation(url string)
- func (f *ΩFormBase) Deserialize(d Decoder, p *Page) (err error)
- func (f *ΩFormBase) DisplayAlert(ctx context.Context, msg string)
- func (f *ΩFormBase) Draw(ctx context.Context, buf *bytes.Buffer) (err error)
- func (f *ΩFormBase) DrawHeaderTags(ctx context.Context, buf *bytes.Buffer)
- func (f *ΩFormBase) DrawingAttributes() *html.Attributes
- func (f *ΩFormBase) Exit(ctx context.Context, err error)
- func (f *ΩFormBase) Init(ctx context.Context, self FormI, path string, id string)
- func (f *ΩFormBase) LoadControls(ctx context.Context)
- func (f *ΩFormBase) PageDrawingFunction() PageDrawFunc
- func (f *ΩFormBase) PopLocation(ctx context.Context)
- func (f *ΩFormBase) PreRender(ctx context.Context, buf *bytes.Buffer) (err error)
- func (f *ΩFormBase) PushLocation(ctx context.Context)
- func (f *ΩFormBase) Refresh()
- func (f *ΩFormBase) Response() *Response
- func (f *ΩFormBase) Run(ctx context.Context) error
- func (f *ΩFormBase) Serialize(e Encoder) (err error)
- func (f *ΩFormBase) ΩisSerializer(i ControlI) bool
Constants ¶
const ( FrameworkErrNone = iota FrameworkErrNoTemplate FrameworkErrRecordNotFound FrameworkErrNotAuthorized )
const ( ResponseWatcher = "watcher" ResponseControls = "controls" ResponseCommandsHigh = "commandsHigh" ResponseCommandsMedium = "commands" ResponseCommandsLow = "commandsLow" ResponseCommandsFinal = "commandsFinal" ResponseRegC = "regc" // register control list ResponseHtml = "html" ResponseValue = "value" ResponseId = "id" ResponseAttributes = "attributes" ResponseCss = "css" ResponseClose = "winclose" ResponseLocation = "loc" ResponseAlert = "alert" ResponseStyleSheets = "ss" ResponseJavaScripts = "js" )
const ( ErrorWrapper = "page.Error" LabelWrapper = "page.Label" DivWrapper = "page.Div" )
Wrapper constants used in the With function
const EncodingVersion = 1 //
const MaxStackDepth = 50
const PrivateActionBase = 1000
const RequiredErrorMessage string = "A value is required"
Variables ¶
var DefaultCheckboxLabelDrawingMode = html.LabelAfter // Setting used by checkboxes and radio buttons to default how they draw labels.
var MaxBufferSize = 10000
var MultipartFormMax int64 = 10000000 // 10MB max in memory file
var PageCacheVersion int32 = 1
PageCacheVersion helps us keep track of when a change to the application changes the pagecache format. It is only needed when serializing the pagecache. Some page cache stores may be difficult to invalidate the whole thing, so this lets lets us invalidate old pagecaches individually. If you implement your own pagecache, you may want to control this independently of goradd, which is why this is exported. Goradd should bump this value whenever the pagecache serialization format changes.
var PagePathPrefix = ""
Functions ¶
func ControlConnectorParams ¶
ConnectorParams returns a list of options setable by the connector dialog (not currently implemented)
func ConvertToBool ¶
func ConvertToBool(v interface{}) bool
ConvertToBool is a helper function that can convert Put or Get values and other possible kinds of values into a bool value.
func DebugErrorPageTmpl ¶
The DebugErrorPageTmpl writes a debug error page to the html output so that it will display the error in the browser, possibly as a popup. Do not use this on the release server, as it may expose details of your application that you do not want exposed.
func GetAssetLocation ¶
func GetAssetUrl ¶
func GetBuffer ¶
GetBuffer returns a buffer from the pool. It will create a new pool if one is not already allocated. This allows you to inject your own replacement BufferPool before the first use of GetBuffer()
func PutBuffer ¶
PutBuffer puts a buffer back into the pool. Be very careful that you do not refer to the buffer after putting it back, including using a slice of a buffer.
func Redirect ¶
func Redirect(url string)
Redirect aborts the current page load and tells the browser to load a different url
func RegisterAssetDirectory ¶
RegisterAssetDirectory registers the given directory as a static file server. The files are served by the normal go static file process. This must happen during application initialization, as the static file directories are added to the MUX at startup time.
func RegisterControlWrapper ¶
func RegisterPage ¶
func RegisterPage(path string, creationFunction FormCreationFunction, formId string)
func RegisterTemplate ¶
func RegisterTemplate(name string, t TemplateExecuter)
func ReleaseErrorPageTmpl ¶
The ReleaseErrorPageTmpl function will output a friendly error message to a user in release mode, and log the error to the Error log.
func ServeAsset ¶
func ServeAsset(w http.ResponseWriter, r *http.Request)
func SetPageCache ¶
func SetPageCache(c PageCacheI)
func SetPageEncoder ¶
func SetPageEncoder(e PageEncoderI)
Types ¶
type ActionParams ¶
type ActionParams struct { // Id is the id assigned when the action is created ID int // Action is an interface to the action itself Action action.ActionI // ControlID is the control that originated the action ControlId string // contains filtered or unexported fields }
ActionParams are sent to the Action() function in controls in response to a user action.
func (*ActionParams) ActionValue ¶
func (a *ActionParams) ActionValue(i interface{}) (ok bool, err error)
ActionValue will attempt to put the Action value into the given object using json.Unmarshal. You should primarily use it to get object or array values out of the Action value. If you are expecting a basic type, use one of the ActionValue* helper functions instead. The given value should be a pointer to an object or variable that is the expected type for the data. ok will be false if no data was found. It will return an error if the data was found, but could not be converted to the given type.
func (*ActionParams) ActionValueBool ¶
func (a *ActionParams) ActionValueBool() bool
func (*ActionParams) ActionValueFloat ¶
func (a *ActionParams) ActionValueFloat() float64
func (*ActionParams) ActionValueInt ¶
func (a *ActionParams) ActionValueInt() int
func (*ActionParams) ActionValueString ¶
func (a *ActionParams) ActionValueString() string
ActionString returns the action value as a string. It will convert to a string, even if the value is not a string.
func (*ActionParams) ControlValue ¶
func (a *ActionParams) ControlValue(i interface{}) (ok bool, err error)
ControlValue will attempt to put the Control value into the given object using json.Unmarshal. You should primarily use it to get object or array values out of the Control value. If you are expecting a basic type, use one of the ControlValue* helper functions instead. The given value should be a pointer to an object or variable that is the expected type for the data. ok will be false if no data was found. It will return an error if the data was found, but could not be converted to the given type.
func (*ActionParams) ControlValueBool ¶
func (a *ActionParams) ControlValueBool() (ret bool)
func (*ActionParams) ControlValueFloat ¶
func (a *ActionParams) ControlValueFloat() float64
func (*ActionParams) ControlValueInt ¶
func (a *ActionParams) ControlValueInt() int
func (*ActionParams) ControlValueString ¶
func (a *ActionParams) ControlValueString() string
ControlString returns the control value as a string. It will convert to a string, even if the value is not a string.
func (*ActionParams) EventValue ¶
func (a *ActionParams) EventValue(i interface{}) (ok bool, err error)
EventValue will attempt to put the Event value into the given object using json.Unmarshal. You should primarily use it to get object or array values out of the Action value. If you are expecting a basic type, use one of the EventValue* helper functions instead. The given value should be a pointer to an object or variable that is the expected type for the data. ok will be false if no data was found. It will return an error if the data was found, but could not be converted to the given type.
func (*ActionParams) EventValueBool ¶
func (a *ActionParams) EventValueBool() bool
func (*ActionParams) EventValueFloat ¶
func (a *ActionParams) EventValueFloat() float64
func (*ActionParams) EventValueInt ¶
func (a *ActionParams) EventValueInt() int
func (*ActionParams) EventValueString ¶
func (a *ActionParams) EventValueString() string
EventValueString returns the event value as a string. It will convert to a string, even if the value is not a string.
type AppContext ¶
AppContext has Goradd application specific nodes
type BufferPoolI ¶
BufferPoolI describes a buffer pool that can be used to improve memory allocation and garbage collection for the frequent memory use.
var BufferPool BufferPoolI
BufferPool is the global buffer pool used by the page drawing system. You can use it to get buffers for you own writes as well. The default buffer pool uses MaxBufferSize to limit the size of buffers that are put back into the pool. If a particular http request required a large buffer to satisfy, this prevents that buffer from hanging around too long. You should set MaxBufferSize to a value that is bigger than most http request sizes.
type Context ¶
type Context struct { HttpContext AppContext }
func GetContext ¶
func (*Context) CheckableValue ¶
func (*Context) CheckableValues ¶
func (*Context) CustomControlValue ¶
func (*Context) FillApp ¶
FillApp fills the app structure with app specific information from the request Do not panic here!
func (*Context) FormValue ¶
Returns the given form variable value, either from post or get variables If the value does not exist, or is a multi-part value, returns false in ok Use FormValues for multipart values
func (*Context) FormValues ¶
Returns the corresponding form value as a string slice. Use this when you are expecting more than one value in the given form variable
func (*Context) RequestMode ¶
func (ctx *Context) RequestMode() RequestMode
type ContextI ¶
type ContextI interface { Http() *HttpContext App() *AppContext }
type Control ¶
type Control struct { base.Base Tag string IsVoidTag bool // tag does not get wrapped with a terminating tag, but just ends instead // ErrorForRequired is the error that will display if a control value is required but not set. ErrorForRequired string // ValidMessage is the message to display if the control has successfully been validated. Leave blank if you don't want a message to show when valid. Can be useful to contrast between invalid and valid controls in a busy form. ValidMessage string // contains filtered or unexported fields }
func (*Control) Action ¶
func (c *Control) Action(ctx context.Context, a ActionParams)
Action processes actions. Typically, the Action function will first look at the id to know how to handle it. This is just an empty implemenation. Sub-controls should implement this.
func (*Control) ActionValue ¶
func (c *Control) ActionValue() interface{}
ActionValue returns the control's action value
func (*Control) AddRelatedRenderScript ¶
AddRelatedRenderScript adds a render script for a related html object. This is primarily used by control implementations.
func (*Control) AddRenderScript ¶
Adds a jQuery command to be executed on the next ajax draw. These commands allow javascript to change an aspect of the control without having to redraw the entire control. This should primarily be used by control implementations only.
func (*Control) AddWrapperClass ¶
func (*Control) DrawChildren ¶
func (*Control) DrawInnerHtml ¶
Returns the inner text of the control, if the control is not a self terminating (void) control. Sub-controls can override this.
func (*Control) DrawTag ¶
Draw the control tag itself. Override to draw the tag in a different way, or draw more than one tag if drawing a compound control.
func (*Control) DrawTemplate ¶
Controls that use templates should use this function signature for the template. That will override this one, and we will then detect that the template was drawn. Otherwise, we detect that no template was defined and it will move on to drawing the controls without a template, or just the text if text is defined.
func (*Control) DrawingAttributes ¶
func (c *Control) DrawingAttributes() *html.Attributes
Returns a set of attributes that should override those set by the user. This allows controls to set attributes just before drawing that should take precedence over other attributes, and that are critical to drawing the tag of the control. This function is designed to only be called by overriding functions, changes will not be remembered.
func (*Control) ExecuteJqueryFunction ¶
ExecuteJqueryFunction will execute the given JQuery function on the given command, with the given parameters. i.e. jQuery("#id").command(params...); will get executed in javascript.
func (*Control) GetActionScripts ¶
GetActionScripts is an internal function called during drawing to recursively gather up all the event related scripts attached to the control and send them to the response.
func (*Control) GobEncode ¶
GobEncode here is implemented to intercept the GobSerializer to only encode an empty structure. We use this as part of our overall serialization stratgey for forms. Controls still need to be registered with gob.
func (*Control) HasAttribute ¶
func (*Control) HasWrapper ¶
func (*Control) Init ¶
Init should be called immediately after a control is created and is responsible for setting up the initial state of a new control. Your subclasses should have their own Init function, and should call the superclass function. This Init function sets up a parent-child relationship with the given parent control, and sets up data structures to use the control in object-oriented ways with virtual functions. The id is the control id that will appear as the id in html. Leave blank for the system to create a unique id for you.
func (*Control) Instructions ¶
func (*Control) IsDisabled ¶
func (*Control) IsDisplayed ¶
func (*Control) IsRendering ¶
func (*Control) IsRequired ¶
func (*Control) MarshalJSON ¶
func (*Control) MarshalState ¶
MarshalState is a helper function for controls to save their basic state, so that if the form is reloaded, the value that the user entered will not be lost. Implementing controls should add items to the given map. Note that the control id is used as a key for the state, so that if you are dynamically adding controls, you should make sure you give a specific, non-changing control id to the control, or the state may be lost.
func (*Control) ParentForm ¶
ParentForm returns the form object that encloses this control.
func (*Control) PostRender ¶
func (*Control) PrivateAction ¶
func (c *Control) PrivateAction(ctx context.Context, a ActionParams)
PrivateAction processes actions that a control sets up for itself, and that it does not want to give the opportunity for users of the control to manipulate or remove those actions. Generally, private actions should call their superclass PrivateAction function too.
func (*Control) PutCustomScript ¶
PutCustomScript is the place where you add javascript that transforms the html into a custom javascript control. Do this by calling functions on the response object. This implementation is a stub.
func (*Control) Remove ¶
func (c *Control) Remove()
Remove removes the current control from its parent. After this is done, the control and all its child items will not be part of the override, but the child items will still be accessible through the control itself.
func (*Control) RemoveChild ¶
RemoveChild removes the given child control from both the control and the override.
func (*Control) RemoveChildren ¶
func (c *Control) RemoveChildren()
RemoveChildren removes all the child controls from this control and the override
func (*Control) RemoveClass ¶
func (*Control) RemoveClassesWithPrefix ¶
func (*Control) RenderAutoControls ¶
RenderAutoControls is an internal function to draw controls marked to autoRender. These are generally used for hidden controls that can be shown without impacting layout, or that are scripts only.
func (*Control) Restore ¶
Restore is called after the control has been deserialized. It creates any required data structures that are not saved in serialization.
func (*Control) SaveState ¶
SaveState sets whether the control should save its value and other state information so that if the form is redrawn, the value can be restored. This function is also responsible for restoring the previously saved state of the control, so call This only after you have set the default state of a control during creation or initialization.
func (*Control) SetActionValue ¶
SetActionValue sets a value that is provided to actions when they are triggered. The value can be a static value or one of the javascript.* objects that can dynamically generate values. The value is then sent back to the action handler after the action is triggered.
func (*Control) SetAttribute ¶
func (*Control) SetBlockParentValidation ¶
SetBlockParentValidation will prevent a parent from validating this control. This is generally useful for panels and other containers of controls that wish to have their own validation scheme. Dialogs in particular need this since they essentially act as a separate form, even though technically they are included in a form.
func (*Control) SetDataAttribute ¶
func (*Control) SetDisabled ¶
func (*Control) SetDisplay ¶
func (*Control) SetEscapeText ¶
SetEscapeText to false to turn off html escaping of the text output. It is on by default.
func (*Control) SetHeightStyle ¶
SetHeightStyle sets the height css property
func (*Control) SetInstructions ¶
func (*Control) SetIsRequired ¶
func (*Control) SetShouldAutoRender ¶
func (*Control) SetValidationError ¶
SetValidationError sets the validation error to the given string. It will also handle setting the wrapper class to indicate an error. Override if you have a different way of handling errors.
func (*Control) SetValidationTargets ¶
SetValidationTargets specifies which controls to validate, in conjunction with the ValidationType setting, giving you very fine-grained control over validation. The default is to use just this control as the target.
func (*Control) SetValidationType ¶
func (c *Control) SetValidationType(typ ValidationType)
SetValidationType specifies how this control validates other controls. Typically its either ValidateNone or ValidateForm. ValidateForm will validate all the controls on the form. ValidateSiblingsAndChildren will validate the immediate siblings of the target controls and their children ValidateSiblingsOnly will validate only the siblings of the target controls ValidateTargetsOnly will validate only the specified target controls
func (*Control) SetVisible ¶
func (*Control) SetWidthStyle ¶
SetWidthStyle sets the width css property
func (*Control) SetWillBeValidated ¶
SetWillBeValidated indicates to the wrapper whether to save a spot for a validation message or not.
func (*Control) SetWrapperAttribute ¶
func (*Control) ShouldAutoRender ¶
func (*Control) T ¶
T sends strings to the translator for translation, and returns the translated string. The language is taken from the session. See the i18n package for more info on that mechanism. Additionally, you can add an i18n.ID() call to add an id to the translation to disambiguate it from similar strings, and you can add a i18n.Comment() call to add an extracted comment for the translators. The message string should be a literal string and not a variable, so that an extractor can extract it from your source to put it into a translation file. This version passes the literal string.
Examples
textbox.T("I have %d things", count, i18n.Comment("This will need multiple translations based on the count value")); textbox.SetLabel(textbox.T("S", i18n.ID("South")));
func (*Control) TPrintf ¶
This is like T(), but works like Sprintf, returning the translated string, but sending the arguments to the message as if the message was an Sprintf format string. The go/text extractor has code that can do interesting things with this kind of string.
func (*Control) TextIsLabel ¶
TextIsLabel is used by the drawing routines to determine if the control's text should be wrapped with a label tag, Meaning the Label itself
func (*Control) UnmarshalJSON ¶
func (*Control) UnmarshalState ¶
UnmarshalState is a helper function for controls to get their state from the stateStore. To implement it, a control should read the data out of the given map. If needed, implemet your own version checking scheme. The given map will be guaranteed to have been written out by the same kind of control as the one reading it. Be sure to call the super-class version too.
func (*Control) UpdateFormValues ¶
UpdateFormValues should be implemented by controls to get their values from the context.
func (*Control) Validate ¶
Validate is designed to be overridden. Overriding controls should call the parent version before doing their own validation.
func (*Control) ValidationMessage ¶
func (*Control) ValidationState ¶
func (c *Control) ValidationState() ValidationState
func (*Control) ValidationType ¶
func (c *Control) ValidationType(e EventI) ValidationType
ValidationType is an internal function to return the validation type. It allows subclasses to override it.
func (*Control) WasRendered ¶
func (*Control) With ¶
With sets the wrapper style for the control, essentially setting the wrapper template function that will be used.
func (*Control) WrapEvent ¶
WrapEvent is an internal function to allow the control to customize its treatment of event processing.
func (*Control) WrapperAttributes ¶
func (c *Control) WrapperAttributes() *html.Attributes
WrapperAttributes returns the actual attributes for the wrapper. Changes WILL be remembered so that subsequent ajax drawing will draw the wrapper correctly. However, it is up to you to refresh the control if you change anything.
func (*Control) ΩT ¶
ΩT is a shortcut for the translator that uses the internal Goradd domain for translations.
func (*Control) ΩisSerializer ¶
ΩisSerializer is used by the automated control serializer to determine how far down the control chain the control has to go before just calling serialize and deserialize
type ControlI ¶
type ControlI interface { ID() string DrawI DrawTag(context.Context) string DrawInnerHtml(context.Context, *bytes.Buffer) error DrawTemplate(context.Context, *bytes.Buffer) error PreRender(context.Context, *bytes.Buffer) error PostRender(context.Context, *bytes.Buffer) error ShouldAutoRender() bool SetShouldAutoRender(bool) DrawAjax(ctx context.Context, response *Response) error DrawChildren(ctx context.Context, buf *bytes.Buffer) error DrawText(ctx context.Context, buf *bytes.Buffer) With(w WrapperI) ControlI HasWrapper() bool Wrapper() WrapperI Parent() ControlI Children() []ControlI SetParent(parent ControlI) Remove() RemoveChild(id string) RemoveChildren() Page() *Page ParentForm() FormI Child(string) ControlI SetAttribute(name string, val interface{}) ControlI SetWrapperAttribute(name string, val interface{}) ControlI Attribute(string) string HasAttribute(string) bool DrawingAttributes() *html.Attributes WrapperAttributes() *html.Attributes AddClass(class string) ControlI RemoveClass(class string) ControlI AddWrapperClass(class string) ControlI SetStyles(*html.Style) SetStyle(name string, value string) ControlI SetWidthStyle(w interface{}) ControlI SetHeightStyle(w interface{}) ControlI PutCustomScript(ctx context.Context, response *Response) HasFor() bool SetHasFor(bool) ControlI Label() string SetLabel(n string) ControlI TextIsLabel() bool Text() string SetText(t string) ControlI ValidationMessage() string SetValidationError(e string) Instructions() string SetInstructions(string) ControlI WasRendered() bool IsRendering() bool IsVisible() bool SetVisible(bool) Refresh() Action(context.Context, ActionParams) PrivateAction(context.Context, ActionParams) SetActionValue(interface{}) ControlI ActionValue() interface{} On(e EventI, a ...action2.ActionI) EventI Off() WrapEvent(eventName string, selector string, eventJs string) string UpdateFormValues(*Context) Validate(ctx context.Context) bool ValidationState() ValidationState ValidationType(EventI) ValidationType // SaveState tells the control whether to save the basic state of the control, so that when the form is reentered, the // data in the control will remain the same. This is particularly useful if the control is used as a filter for the // contents of another control. SaveState(context.Context, bool) MarshalState(m maps.Setter) UnmarshalState(m maps.Loader) // Shortcuts for translation ΩT(format string) string T(format string, params ...interface{}) string TPrintf(format string, params ...interface{}) string // Serialization helpers Restore(self ControlI) // API SetIsRequired(r bool) ControlI Serialize(e Encoder) (err error) Deserialize(d Decoder, p *Page) (err error) ΩisSerializer(i ControlI) bool // contains filtered or unexported methods }
type ControlLoc ¶
type ControlLoc int8
const ( ControlIsNil ControlLoc = iota ControlIsHere ControlIsInPage )
type ControlTemplateFunc ¶
type ControlWrapperFunc ¶
type DbError ¶
type Decoder ¶
Decoder defines objects that can be decoded from a pagestate. If the object does not implement this, we will look for GobDecode support.
type DivWrapperType ¶
type DivWrapperType struct { }
func NewDivWrapper ¶
func NewDivWrapper() *DivWrapperType
func (DivWrapperType) TypeName ¶
func (w DivWrapperType) TypeName() string
func (DivWrapperType) ΩAjaxRender ¶
func (w DivWrapperType) ΩAjaxRender(ctx context.Context, response *Response, c ControlI)
func (DivWrapperType) ΩModifyDrawingAttributes ¶
func (w DivWrapperType) ΩModifyDrawingAttributes(ctrl ControlI, a *html.Attributes)
func (DivWrapperType) ΩNewI ¶
func (w DivWrapperType) ΩNewI() WrapperI
func (DivWrapperType) ΩSetValidationMessageChanged ¶
func (w DivWrapperType) ΩSetValidationMessageChanged()
func (DivWrapperType) ΩSetValidationStateChanged ¶
func (w DivWrapperType) ΩSetValidationStateChanged()
type Error ¶
type Error struct { // the error string Err error // the time the error occurred Time time.Time // the copied context when the error occurred Ctx *Context // unwound Stack info Stack []StackFrame }
The error structure, specifically designed to manage panics during request handling
type ErrorPageFuncType ¶
The ErrorPageTemplate type specifies the signature for the error template function. You can replace the built-in error function with your own function by setting the config.ErrorPage value. html is the html that was able to be generated before the error occurred, which can be helpful in tracking down the source of an error.
var ErrorPageFunc ErrorPageFuncType
type ErrorWrapperType ¶
An ErrorWrapperType wraps a control with a validation message
func NewErrorWrapper ¶
func NewErrorWrapper() *ErrorWrapperType
func (*ErrorWrapperType) TypeName ¶
func (w *ErrorWrapperType) TypeName() string
func (*ErrorWrapperType) ΩAjaxRender ¶
func (w *ErrorWrapperType) ΩAjaxRender(ctx context.Context, response *Response, c ControlI)
ΩAjaxRender is called by the framework to draw any changes to the wrapper that we have recorded. This has to work closely with the wrapper template so that it would create the same effect as if that entire control had been redrawn
func (*ErrorWrapperType) ΩModifyDrawingAttributes ¶
func (w *ErrorWrapperType) ΩModifyDrawingAttributes(c ControlI, a *html.Attributes)
ΩModifyDrawingAttributes should only be called by the framework during a draw. It changes attributes of the wrapped control based on the validation state of the control.
func (ErrorWrapperType) ΩNewI ¶
func (w ErrorWrapperType) ΩNewI() WrapperI
Copy copies itself and returns it. This is used when a new wrapper is created from a named type.
func (*ErrorWrapperType) ΩSetValidationMessageChanged ¶
func (w *ErrorWrapperType) ΩSetValidationMessageChanged()
func (*ErrorWrapperType) ΩSetValidationStateChanged ¶
func (w *ErrorWrapperType) ΩSetValidationStateChanged()
type Event ¶
type Event struct { JsEvent string // contains filtered or unexported fields }
Event represents a javascript event that triggers an action. Create it with a call to NewEvent(), or one of the predefined events in the event package, like event.Click()
func (*Event) ActionValue ¶
ActionValue is a value that will be returned to the actions that will be process by this event. Specify a static value, or javascript objects that will gather data at the time the event fires. The event will appear in the ActionParams as the EventValue. Example: ActionValue(javascript.ModelName("ui")) will return the "ui" variable that is part of the event call.
func (*Event) Blocking ¶
Call Blocking to cause this event to prevent other events from firing after this fires, but before it processes. If another event fires between the time when this event fires and when a response is received, it will be lost.
func (*Event) Condition ¶
Condition specifies a javascript condition to check before triggering the event. The given string should be javascript code that evaluates to a boolean value.
func (*Event) GetActionValue ¶
func (e *Event) GetActionValue() interface{}
func (*Event) PreventBubbling ¶
Call PreventBubbling to cause the event to not bubble to enclosing objects.
func (*Event) PreventingDefault ¶
Call PreventingDefault to cause the event not to do the default action.
func (*Event) Selector ¶
Selector specifies a CSS filter that is used to check for bubbled events. This allows the event to be fired from child controls.
func (*Event) Terminating ¶
Call Terminating to cause the event not to bubble or do the default action.
func (*Event) Validate ¶
func (e *Event) Validate(v ValidationType) EventI
Validate overrides the controls validation setting just for this event.
func (*Event) ValidationTargets ¶
ValidationTargets overrides the control's validation targets just for this event.
type EventI ¶
type EventI interface { // Condition sets a javascript condition that will be used to decide whether to fire the event. The condition // will be evaluated when the event fires, and if its true, the associated action will be queued. Condition(string) EventI // Delay sets a delay for when the action happens after the event is fired, in milliseconds. Delay(int) EventI // Selector is a jQuery CSS selector that will filter bubbled events, only allowing events from the specified sub-items. Selector(string) EventI // Blocking will create an event that prevents all other events from firing before it is handled. Events that get // fired during this time are lost. This is particularly useful for Ajax or Server events that should not be // interrupted. Blocking() EventI // Terminating creates an event that does not bubble, nor will it do the browser default for the event. Terminating() EventI // Validate overrides the default validation specified by the control. Validate(v ValidationType) EventI // ValidationTargets overrides the validation targets specified by the control. ValidationTargets(targets ...string) EventI // ActionValue lets you specify a value that will be sent with the resulting action, and that will be accessible // through the EventValue() call on the ActionParams structure in the action handler. This is useful for Ajax and // Server actions primarily. This can be a static value, or a javascript.* type object to get dynamic values from javascript. ActionValue(interface{}) EventI // String returns a description of the event, primarily for debugging String() string // contains filtered or unexported methods }
EventI defines the interface for an event. Many of the routines implement a Builder pattern, allowing you to add options by chaining function calls on the event.
type FastPageCache ¶
FastPageCache is an in memory override cache that does no serialization and uses an LRU cache of override objects. Objects that are too old are removed, and if the cache is full, the oldest item(s) will be removed. Pages that are set multiple times will be pushed to the top. Whenever an item is set, we could potentially garbage collect. This cache is only appropriate when the pagecache itself is operating on a single machine.
func NewFastPageCache ¶
func NewFastPageCache(maxEntries int, TTL int64) *FastPageCache
func (*FastPageCache) Get ¶
func (o *FastPageCache) Get(pageId string) *Page
Get returns the override based on its override id. If not found, will return null.
func (*FastPageCache) Has ¶
func (o *FastPageCache) Has(pageId string) bool
Has tests to see if the given page id is in the page cache, without actually loading the page
func (*FastPageCache) NewPageID ¶
func (o *FastPageCache) NewPageID() string
Returns a new override id
func (*FastPageCache) Set ¶
func (o *FastPageCache) Set(pageId string, page *Page)
Puts the override into the override cache, and updates its access time, pushing it to the end of the removal queue Page must already be assigned a state ID. Use NewPageId to do that.
type FormCreationFunction ¶
type FormI ¶
type FormI interface { ControlI // Init initializes the base structures of the form. Do this before adding controls to the form. Init(ctx context.Context, self FormI, path string, id string) PageDrawingFunction() PageDrawFunc LoadControls(ctx context.Context) AddHeadTags() DrawHeaderTags(ctx context.Context, buf *bytes.Buffer) Response() *Response AddStyleSheetFile(path string, attributes *html.Attributes) AddJavaScriptFile(path string, forceHeader bool, attributes *html.Attributes) DisplayAlert(ctx context.Context, msg string) AddJQueryUI() // Lifecycle calls Run(ctx context.Context) error Exit(ctx context.Context, err error) // contains filtered or unexported methods }
type FrameworkError ¶
type FrameworkError struct {
Err int
}
FrameworkError is an expected error that is part of the framework. Usually you would respond to the error by displaying a message to the user, but not always.
func NewFrameworkError ¶
func NewFrameworkError(err int) FrameworkError
func (FrameworkError) Error ¶
func (e FrameworkError) Error() string
type GobDeserializer ¶
func (GobDeserializer) Decode ¶
func (e GobDeserializer) Decode(v interface{}) (err error)
func (GobDeserializer) DecodeControl ¶
func (e GobDeserializer) DecodeControl(p *Page) (c ControlI, err error)
DecodeControl decodes a control from the stream and returns it as a ControlI.
type GobPageEncoder ¶
type GobPageEncoder struct { }
func (GobPageEncoder) NewDecoder ¶
func (e GobPageEncoder) NewDecoder(b *bytes.Buffer) Decoder
func (GobPageEncoder) NewEncoder ¶
func (e GobPageEncoder) NewEncoder(b *bytes.Buffer) Encoder
type GobSerializer ¶
func (GobSerializer) Encode ¶
func (e GobSerializer) Encode(v interface{}) (err error)
Serialize sends
func (GobSerializer) EncodeControl ¶
func (e GobSerializer) EncodeControl(c ControlI) (err error)
type HttpContext ¶
type HttpContext struct { Req *http.Request URL *url.URL Host string RemoteAddr string Referrer string Cookies map[string]*http.Cookie Files map[string][]*multipart.FileHeader Header http.Header // contains filtered or unexported fields }
Typical things we can extract from http
type HttpError ¶
type HttpError struct {
// contains filtered or unexported fields
}
func (*HttpError) SetResponseHeader ¶
type LabelWrapperType ¶
type LabelWrapperType struct { ErrorWrapperType // contains filtered or unexported fields }
func NewLabelWrapper ¶
func NewLabelWrapper() *LabelWrapperType
func (*LabelWrapperType) Copy ¶
func (w *LabelWrapperType) Copy() *LabelWrapperType
Copy returns a copy of the wrapper
func (*LabelWrapperType) HasLabelAttributes ¶
func (w *LabelWrapperType) HasLabelAttributes() bool
HasLabelAttributes returns true if attributes are defined on the wrapper itself
func (*LabelWrapperType) LabelAttributes ¶
func (w *LabelWrapperType) LabelAttributes() *html.Attributes
LabelAttributes returns attributes that will apply to the label. Changes will be remembered, but will not be applied unless you redraw the control.
func (*LabelWrapperType) TypeName ¶
func (w *LabelWrapperType) TypeName() string
func (*LabelWrapperType) ΩModifyDrawingAttributes ¶
func (w *LabelWrapperType) ΩModifyDrawingAttributes(c ControlI, a *html.Attributes)
ΩModifyDrawingAttributes is a framework function that allows wrappers to modify a control's attributes at draw time. Label wrappers will set the aria-labeledby attribute in the control if needed.
func (*LabelWrapperType) ΩNewI ¶
func (w *LabelWrapperType) ΩNewI() WrapperI
Copy copies itself and returns it. This is used when a new wrapper is created from a named type.
func (*LabelWrapperType) ΩWrap ¶
func (w *LabelWrapperType) ΩWrap(ctx context.Context, ctrl ControlI, html string, buf *bytes.Buffer)
ΩWrap wraps the given control and html output from that control with html from the LabelWrapperTemplate. The LabelWrapperTemplate will associate a label tag with the control, and also add tags to display validation errors and information or instructions associated with the control. See the template_source/wrapper_label.tpl.got source file for details on how this is done.
type Page ¶
type Page struct { // BodyAttributes contains the attributes that will be output with the body tag. It should be set before the // form draws, like in the AddHeadTags function. BodyAttributes string // contains filtered or unexported fields }
The Page object is the top level drawing object, and is essentially a wrapper for the form. The Page draws the html, head and body tags, and includes the one Form object on the page. The page also maintains a record of all the controls included on the form.
func (*Page) AddHtmlHeaderTag ¶
AddHtmlHeaderTag adds the given tag to the head section of the page.
func (*Page) ClearResponseHeaders ¶
func (p *Page) ClearResponseHeaders()
ClearResponseHeaders removes all the current response headers.
func (*Page) DrawAjax ¶
DrawAjax renders the page during an ajax call. Since the page itself is already rendered, it simply hands off this responsibility to the form.
func (*Page) GenerateControlID ¶
Generates unique control ids. If you want to do your own id generation, or modifying of given ids, implement that in an override to the control.Init function. The given id is one that the user supplies. User provided ids and generated ids can be further munged by providing an id prefix through SetControlIdPrefix().
func (*Page) GetControl ¶
GetControl returns the control with the given id. If not found, it returns nil.
func (*Page) GobEncode ¶
GobEncode here is implemented to intercept the GobSerializer to only encode an empty structure. We use this as part of our overall serialization stratgey for forms. Controls still need to be registered with gob.
func (*Page) LanguageCode ¶
LanguageCode returns the language code that will be put in the lang attribute of the html tag. It is taken from the i18n package.
func (*Page) MarshalJSON ¶
func (*Page) Path ¶
Path returns the URL path that corresponds to this page. This is what is output in the form's action tag so that the form calls back onto itself.
func (*Page) PushRedraw ¶
func (p *Page) PushRedraw()
PushRedraw will cause the form to refresh in between events. This will cause the client to pull the ajax response. Its possible that this will happen while drawing. We avoid the race condition by sending the message anyways, and allowing the client to send an event back to us, essentially using the javascript event mechanism to synchronize us. We might get an unnecessary redraw, but that is not a big deal.
func (*Page) Restore ¶
func (p *Page) Restore()
Restore is called immediately after the page has been unserialized, to restore data that did not get serialized.
func (*Page) SetControlIdPrefix ¶
Sets the prefix for control ids. Some javascript frameworks (i.e. jQueryMobile) require that control ids be unique across the application, vs just in the page, because they create internal caches of control ids. This allows you to set a per page prefix that will be added to all control ids to make them unique across the whole application. However, its up to you to make sure the names are unique per page.
func (*Page) SetResponseHeader ¶
SetResponseHeader sets a value in the html response header. You generally would only need to do this if your are outputting custom content, like a pdf file.
func (*Page) SetTitle ¶
Call SetTitle to set the content of the <title> tag to be output in the head of the page.
func (*Page) StateID ¶
StateID returns the page state id. This is output by the form so that we can recover the saved state of the page each time we call into the application.
func (*Page) Title ¶
Title returns the content of the <title> tag that will be output in the head of the page.
func (*Page) UnmarshalJSON ¶
type PageCacheI ¶
type PageCacheI interface { Set(pageId string, page *Page) Get(pageId string) *Page NewPageID() string Has(pageId string) bool }
func GetPageCache ¶
func GetPageCache() PageCacheI
GetPageCache returns the page cache. Used internally by goradd.
type PageEncoderI ¶
type PageManager ¶
type PageManager struct {
// contains filtered or unexported fields
}
func GetPageManager ¶
func GetPageManager() *PageManager
func NewPageManager ¶
func NewPageManager() *PageManager
func (*PageManager) HasPage ¶
func (m *PageManager) HasPage(pageStateId string) bool
func (*PageManager) IsPage ¶
func (m *PageManager) IsPage(path string) bool
type PageManagerI ¶
type PageManagerI interface {
RegisterPage(path string, creationFunction FormCreationFunction)
}
type PageRenderStatus ¶
type PageRenderStatus int
const ( PageIsNotRendering PageRenderStatus = iota // FormBase has started rendering but has not finished PageIsRendering )
Future note. Below is for general information but should NOT be used to synchronize multiple drawing routines An architecture using channels to synchronize page changes and drawing would be better For now, except for testing, we should not get in a situation where multiple copies of a form are being used.
type RequestMode ¶
type RequestMode int
const ( Server RequestMode = iota // calling back in to currently showing override using a standard form post Http // new override request Ajax // calling back in to a currently showing override using an ajax request CustomAjax // calling an entry point from ajax, but not through our js file. REST API perhaps? Cli // From command line )
func (RequestMode) String ¶
func (m RequestMode) String() string
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
func NewResponse ¶
func NewResponse() Response
func (*Response) CloseWindow ¶
func (r *Response) CloseWindow()
func (*Response) ExecuteControlCommand ¶
func (*Response) ExecuteJavaScript ¶
ExecuteJavaScript will execute the given code with the given priority. Note that all javascript code is run in strict mode.
func (*Response) ExecuteJsFunction ¶
Call the given function with the given arguments. If just a function label, then the window object is searched. The function can be inside an object accessible from the global namespace by separating with periods.
func (*Response) ExecuteSelectorFunction ¶
func (r *Response) ExecuteSelectorFunction(selector string, functionName string, args ...interface{})
Calls a function on a jQuery selector
func (*Response) JavaScript ¶
*
- Function renders all the Javascript commands as output to the client browser. This is a mirror of what
- occurs in the success function in the qcubed.js ajax code. *
- @param bool $blnBeforeControls True to only render the javascripts that need to come before the controls are defined.
- This is used to break the commands issued into two groups.
- @static
- @return string
func (*Response) MarshalJSON ¶
Return the JSON for use by the form ajax response. Will essentially do the same thing as above, but working in cooperation with the javascript file to process these through an ajax response.
func (*Response) SetControlAttribute ¶
func (*Response) SetControlHtml ¶
func (*Response) SetControlValue ¶
func (*Response) SetLocation ¶
type ResponseCommand ¶
type ResponseCommand struct {
// contains filtered or unexported fields
}
ResponseCommand is a response packet that leads to execution of a javascript function
func (ResponseCommand) MarshalJSON ¶
func (r ResponseCommand) MarshalJSON() (buf []byte, err error)
type ResponseControl ¶
type ResponseControl struct {
// contains filtered or unexported fields
}
A response packet that leads to the manipulation or replacement of an html object
func (ResponseControl) MarshalJSON ¶
func (r ResponseControl) MarshalJSON() (buf []byte, err error)
type Serializable ¶
Serializable defines the interface that allows an object to be encodable using a pre-set encoder. This saves time on memory allocations/deallocations, which might be extensive. Controls are Serializable by default. Other objects that contain controls, or that are not gob.Encoders should implement this as well if they are part of the pagestate.
type SerializedPageCache ¶
SerializedPageCache is an in memory override cache that does serialization and uses an LRU cache of override objects. Use the serialized override cache during development to ensure that you can eventually move your override cache to a database or a separate machine so that your application is scalable. Objects that are too old are removed, and if the cache is full, the oldest item(s) will be removed. Pages that are set multiple times will be pushed to the top. Whenever an item is set, we could potentially garbage collect.
func NewSerializedPageCache ¶
func NewSerializedPageCache(maxEntries int, TTL int64) *SerializedPageCache
func (*SerializedPageCache) Get ¶
func (o *SerializedPageCache) Get(pageId string) *Page
Get returns the page based on its page id. If not found, will return null.
func (*SerializedPageCache) Has ¶
func (o *SerializedPageCache) Has(pageId string) bool
func (*SerializedPageCache) NewPageID ¶
func (o *SerializedPageCache) NewPageID() string
Returns a new override id
func (*SerializedPageCache) Set ¶
func (o *SerializedPageCache) Set(pageId string, page *Page)
Puts the override into the override cache, and updates its access time, pushing it to the end of the removal queue Page must already be assigned a state ID. Use NewPageId to do that.
type StackFrame ¶
type TemplateExecuter ¶
TemplateExecuter is an interface that will work with either text/template or html/template types of templates
func GetTemplate ¶
func GetTemplate(name string) TemplateExecuter
type ValidationState ¶
type ValidationState int
ValidationState is used internally by the framework to determine how the control's wrapper handles drawing validation error messages. Different wrappers use it to set classes or attributes of the error message or the overall control.
const ( // ValidationWaiting is the default for controls that accept validation. It means that the control expects to be validated, // but has not yet been validated. Wrappers should save a spot for the error message of this control so that if // an error appears, it will not change the layout of the form. ValidationWaiting ValidationState = iota // ValidationNever indicates that the control will never fail validation. Essentially it indicates that the wrapper does not // need to save a spot for an error message for this control. ValidationNever // ValidationValid indicates the control has been validated. This state gets entered if some control on the form has failed validation, but // this control passed validation. You can choose to display a special message, or a special color, etc., to // indicate to the user that this is not the source of the validation problem, or do nothing. ValidationValid // ValidationInvalid indicates the control has failed validation, and the wrapper should somehow call that out to the user. The error message // should be displayed at a minimum, but likely other things should happen as well, like a special color, and // aria attributes should be set. ValidationInvalid )
type ValidationType ¶
type ValidationType int
ValidationType is used by active controls, like buttons, to determine what other items on the form will get validated when the button is pressed. You can set the ValidationType for a control, but you can also set it for individual events and override the control's validation setting.
const ( ValidateDefault ValidationType = iota // This is used by the event to indicate it is not overriding. ValidateNone // Force no validation. ValidateForm ValidateSiblingsAndChildren // container validations. Will include validating the current control. ValidateSiblingsOnly ValidateChildrenOnly // ValidateContainer will use the validation setting of a parent control with ValidateSiblingsAndChildren, ValidateSiblingsOnly, // ValidateChildrenOnly, or ValidateTarget as the stopping point for validation. ValidateContainer // ValidateTargetsOnly will only validate the specified targets ValidateTargetsOnly )
type WrapperI ¶
type WrapperI interface { // ΩWrap is used by the framework to wrap the control and html with the wrapper's html tags. ΩWrap(ctx context.Context, ctrl ControlI, html string, buf *bytes.Buffer) // ΩNewI returns a new wrapper. It is used by the wrapper registry to return a named wrapper. ΩNewI() WrapperI // ΩSetValidationMessageChanged notifies the wrapper that the validation message has changed. ΩSetValidationMessageChanged() // ΩSetValidationStateChanged notifies the wrapper that the validation state has changed. ΩSetValidationStateChanged() // ΩAjaxRender does an ajax render of the wrapper. ΩAjaxRender(ctx context.Context, response *Response, c ControlI) // TypeName returns the named type of the wrapper. TypeName() string // ΩModifyDrawingAttributes is used by the framework to allow the wrapper to modify the attributes of the control and draw time. ΩModifyDrawingAttributes(ctrl ControlI, attributes *html.Attributes) }
WrapperI defines the control wrapper interface. Generally you will not call any of these functions. The interface is used by the framework to control wrapper drawing. To call wrapper specific functions, cast to the specific wrapper type.
func NewWrapper ¶
NewWrapper returns a newly allocated wrapper from the wrapper registry.
type ΩFormBase ¶
type ΩFormBase struct { Control // contains filtered or unexported fields }
ΩFormBase is a base for the FormBase struct that is in the control package. Normally, you should not descend your forms from here, but rather from the control.Form struct. It is the basic control structure for the application and also serves as the drawing mechanism for the <form> tag in the html output.
func (*ΩFormBase) AddFontAwesome ¶
func (f *ΩFormBase) AddFontAwesome()
AddFontAwesome adds the font-awesome files fo the form
func (*ΩFormBase) AddGoraddFiles ¶
func (f *ΩFormBase) AddGoraddFiles()
AddGoraddFiles adds the various goradd files to the form
func (*ΩFormBase) AddHeadTags ¶
func (f *ΩFormBase) AddHeadTags()
AddHeadTags is a lifecycle call that happens when a new form is created. This is where you should call AddHtmlHeaderTag or SetTitle on the page to set tags that appear in the <head> tag of the page. Head tags cannot be changed after the page is created.
func (*ΩFormBase) AddJQuery ¶
func (f *ΩFormBase) AddJQuery()
AddJQuery adds the jquery javascript to the form
func (*ΩFormBase) AddJQueryUI ¶
func (f *ΩFormBase) AddJQueryUI()
AddJQueryUI adds the JQuery UI javascript to the form. This is not loaded by default, but many add-ons use it, so its here for convenience.
func (*ΩFormBase) AddJavaScriptFile ¶
func (f *ΩFormBase) AddJavaScriptFile(path string, forceHeader bool, attributes *html.Attributes)
AddJavaScriptFile registers a JavaScript file such that it will get loaded on the page. If forceHeader is true, the file will be listed in the header, which you should only do if the file has some preliminary javascript that needs to be executed before the dom loads. Otherwise, the file will be loaded after the dom is loaded, allowing the browser to show the page and then load the javascript in the background, giving the appearance of a more responsive website. If you add the file during an ajax operation, the file will be loaded dynamically by the goradd javascript. Controls generally should call This during the initial creation of the control if the control requires additional javascript to function.
The path is either a url, or an internal path to the location of the file in the development environment.
func (*ΩFormBase) AddMasterJavaScriptFile ¶
Add a javascript file that is a concatenation of other javascript files the system uses. This allows you to concatenate and minimize all the javascript files you are using without worrying about libraries and controls that are adding the individual files through the AddJavaScriptFile function
func (*ΩFormBase) AddRelatedFiles ¶
func (f *ΩFormBase) AddRelatedFiles()
AddRelatedFiles adds related javascript and style sheet files. This is the default to get the minimum goradd installation working., The order is important, so if you override this, be sure these files get loaded before other files.
func (*ΩFormBase) AddStyleSheetFile ¶
func (f *ΩFormBase) AddStyleSheetFile(path string, attributes *html.Attributes)
AddStyleSheetFile registers a StyleSheet file such that it will get loaded on the page. The file will be loaded on the page at initial draw in the header, or will be inserted into the file if the page is already drawn. The path is either a url, or an internal path to the location of the file in the development environment. AppModeDevelopment files will automatically get copied to the local assets directory for easy deployment and so that the MUX can find the file and serve it (This happens at draw time). The attributes will be extra attributes included with the tag, which is useful for things like crossorigin and integrity attributes.
func (*ΩFormBase) ChangeLocation ¶
func (*ΩFormBase) Draw ¶
Draw renders the form. Even though forms are technically controls, we use a custom drawing routine for performance reasons and for control.
func (*ΩFormBase) DrawHeaderTags ¶
DrawHeaderTags is called by the page drawing routine to draw its header tags If you override this, be sure to call this version too
func (*ΩFormBase) DrawingAttributes ¶
func (f *ΩFormBase) DrawingAttributes() *html.Attributes
func (*ΩFormBase) Exit ¶
Exit is a lifecycle function that gets called after the form is processed, just before control is returned to the client. err will be set if an error response was detected.
func (*ΩFormBase) Init ¶
Init initializes the form control. Note that ctx might be nil if we are unit testing.
func (*ΩFormBase) LoadControls ¶
LoadControls is a lifecycle call that happens after a form is first created. It is the place to initialize the value of the controls in the form based on variables sent to the form.
func (*ΩFormBase) PageDrawingFunction ¶
func (f *ΩFormBase) PageDrawingFunction() PageDrawFunc
PageDrawingFunction returns the function used to draw the page object. If you want a custom drawing function for your page, implement this function in your form override.
func (*ΩFormBase) PopLocation ¶
PopLocation pops the most recent location off of the location stack and goes to that location.
func (*ΩFormBase) PushLocation ¶
PushLocation pushes the URL that got us to the current page on to the location stack.
func (*ΩFormBase) Response ¶
Response returns the form's response object that you can use to queue up javascript commands to the browser to be sent on the next ajax or server request
func (*ΩFormBase) Run ¶
Run is a lifecycle function that gets called whenever a page is run, either by a whole page load, or an ajax call. Its a good place to validate that the current user should have access to the information on the page. Returning an error will result in the error message being displayed.
func (*ΩFormBase) ΩisSerializer ¶
ΩisSerializer is used by the automated control serializer to determine how far down the control chain the control has to go before just calling serialize and deserialize
Source Files ¶
- action.go
- buffer.go
- context.go
- control.go
- debug_error_page.go
- errors.go
- event.go
- form_base.go
- page.go
- page_cache.go
- page_encoder.go
- page_manager.go
- page_template.go
- release_error_page.go
- response.go
- static_file_server.go
- template_pool.go
- wrapper.go
- wrapper_div.tpl.go
- wrapper_error.tpl.go
- wrapper_label.tpl.go
Directories ¶
Path | Synopsis |
---|---|
The action package defines actions that you can trigger using events.
|
The action package defines actions that you can trigger using events. |
The widget package contains supported composite and special purpose controls that are not part of the html standard
|
The widget package contains supported composite and special purpose controls that are not part of the html standard |