Suppose a task is to add a button in Pier to execute code. One way to do that is (code download):
Object subclass: #PRAdHocObject instanceVariableNames: 'parameter' classVariableNames: '' package: 'Pier-Forms'
PRAdHocObject>>parameter: aString parameter := aString PRAdHocObject>>parameter ^ parameter ifNil: [ parameter := '' ]
PRAdHocObject>>descriptionParameter <magritteDescription> ^ MAStringDescription new parameterName: 'parameter'; accessor: #parameter; beSearchable; priority: 120; label: 'Parameter'; beRequired; beEditable; yourself
PRViewComponent subclass: #PRAdHocFormView instanceVariableNames: '' classVariableNames: '' package: 'Pier-Forms' PRAdHocFormView class>>isAbstract ^ false
PRAdHocFormView>>renderContentOn: html | component | (self context isValidCommand: PREditCommand) ifTrue: [ html form: [ html render: (component := PRAdHocObject new asComponent). html submitButton callback: [ component save. Transcript show: 'The button was pushed: '; show: component model parameter; cr ]; with: 'Push' ] ] ifFalse: [ html render: 'Edit is not valid in this context - no button to push' ]
PRStructure subclass: #PRAdHocForm instanceVariableNames: '' classVariableNames: '' package: 'Pier-Forms'
PRAdHocForm>>viewComponentClass ^ PRAdHocFormView
WebBrowser openOn: 'http://localhost:8080/pier'.

PRAddCommand>>#structureClasses, along with the the permissions to add that class for the user. Either use an admin user or add the permission under the Change Owner link


After the button is clicked, the following should appear in the transcript:
The button was pushed: This is the parameter as text
Unfortunately this does not provide the operator much feedback that the button was clicked, but adding that code would double the size of the example.
Leave your comment