Package com.storedobject.ui
Class SteppedView
java.lang.Object
com.storedobject.vaadin.View
com.storedobject.ui.SteppedView
- All Implemented Interfaces:
Executable
,Reentrant
,HasLogic
,Transactional
,ClickHandler
,ExecutableView
,ValueChangeHandler
,com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<? extends com.vaadin.flow.component.Component>>
,com.vaadin.flow.component.HasValue.ValueChangeListener
,Serializable
,Runnable
,EventListener
- Direct Known Subclasses:
SteppedDataForm
,SteppedObjectForm
Stepped View allows you to create a multi-stepped
View
.- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.storedobject.vaadin.ClickHandler
ClickHandler.ModifiedClickEvent<C extends com.vaadin.flow.component.Component>
-
Constructor Summary
ConstructorDescriptionSteppedView
(int numberOfSteps) Constructor.SteppedView
(int numberOfSteps, String caption) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExtraButton
(Button button) Add extra button to the footer.static void
align
(com.vaadin.flow.component.Component component, CSSGrid.Position position) Align (vertically) a component within the view's content area.protected void
back
(int step) This method is invoked when you go back to the previous step from this step.void
cancel()
This method will be invoked when "Cancel" button is pressed.static void
center
(com.vaadin.flow.component.Component component) Center (horizontally and vertically) a component within the view's content area.protected boolean
commit
(int step) This method is invoked before invokingcomplete(int)
and if it raises any error or returnsfalse
, forward movement will be stopped.void
complete()
This method is invoked when the all steps are successfully completed.protected boolean
complete
(int step) This method is invoked when you complete a step.protected void
enter
(int step) This method is invoked when you enter into this step.boolean
finish()
Invoke the finish (Equivalent of pressing the "Finish" button).protected void
This method will be invoked once forms for all steps are constructed.getStepCaption
(int step) protected com.vaadin.flow.component.Component
getStepComponent
(int step) Get the component to be used for the respective step.protected String
getStepLabel
(int step) Get a label for the step.int
goToStep
(int step) Traverse to a particular step from the current step.void
Hide the "Back" button.void
Hide the "Cancel" button.void
Hide the "Finish" button.void
Hide the "Next" button.protected void
initUI()
This method is invoked when the view wants to determine its "content" to be displayed and nothing exists at that moment.boolean
Check if the current step is the final step.boolean
Check if the current step is the first step.static void
justify
(com.vaadin.flow.component.Component component, CSSGrid.Position position) Justify (horizontally) a component within the view's content area.boolean
nextStep()
Go to the next step (Equivalent of pressing the "Next" button).boolean
Go to the previous step (Equivalent of pressing the "Back" button).void
setBackLabel
(String label) Set the label on the "Back" button.void
setCancelLabel
(String label) Set the label on the "Cancel" button.void
setFinishLabel
(String label) Set the label on the "Finish" button.void
setNextLabel
(String label) Set the label on the "Next" button.void
Unhide the "Back" button.void
Unhide the "Cancel" button.void
Unhide the "Finish" button.void
Unhide the "Next" button.Methods inherited from class com.storedobject.vaadin.View
abort, aborted, addClosedListener, addOpenedListener, clean, close, createCloseableView, createWindow, decorateComponent, execute, execute, execute, executing, focus, focus, focusAny, getApplication, getCaption, getComponent, getContent, getCreatedBy, getEmbeddedView, getMenuItem, getMenuItem, getView, invoke, isFullScreen, isScrollable, isWindowMode, select, setCaption, setComponent, setCreatedBy, setDefaultPadding, setEmbeddedView, setFirstFocus, setFullScreen, setScrollable, setWindowMode, skipFirstFocus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.storedobject.vaadin.ClickHandler
clicked, doubleClicked, onComponentEvent, rightClicked
Methods inherited from interface com.storedobject.common.Executable
act
Methods inherited from interface com.storedobject.vaadin.ExecutableView
abort, clean, clearAlerts, clicked, close, createMenuItem, error, execute, getApplication, getCaption, getMenuIconName, getMenuItem, getView, getView, invoke, isCloseable, isFullScreen, isHomeView, log, log, message, returnedFrom, run, setCaption, setClickable, speak, trackValueChange, tray, valueChanged, warning
Methods inherited from interface com.storedobject.common.Reentrant
isReentrant
Methods inherited from interface com.storedobject.ui.Transactional
commit, execute, getLogic, getTransactionManager, run, setLogic, transact, transact, transactControl, transactControl
Methods inherited from interface com.storedobject.vaadin.ValueChangeHandler
valueChanged
-
Constructor Details
-
Method Details
-
formsConstructed
protected void formsConstructed()This method will be invoked once forms for all steps are constructed. -
initUI
protected void initUI()Description copied from class:View
This method is invoked when the view wants to determine its "content" to be displayed and nothing exists at that moment.View.setComponent(Component)
may be called from within this method. -
getStepCaption
-
goToStep
public int goToStep(int step) Traverse to a particular step from the current step. Traversal may not be successful depending on the conditions and validations at the intermediary steps.- Parameters:
step
- Step to jump to- Returns:
- The step to which traversal is successful.
-
nextStep
public boolean nextStep()Go to the next step (Equivalent of pressing the "Next" button).- Returns:
- True if successful.
-
previousStep
public boolean previousStep()Go to the previous step (Equivalent of pressing the "Back" button).- Returns:
- True if successful.
-
finish
public boolean finish()Invoke the finish (Equivalent of pressing the "Finish" button). This will not be successful if not called from the final step.- Returns:
- True if successful.
-
isFirstStep
public boolean isFirstStep()Check if the current step is the first step.- Returns:
- True or false.
-
isFinalStep
public boolean isFinalStep()Check if the current step is the final step.- Returns:
- True or false.
-
addExtraButton
Add extra button to the footer. Button will be visible in all steps unless its visibility is programmatically controlled.- Parameters:
button
- Button to add
-
hideBackButton
public void hideBackButton()Hide the "Back" button. -
hideNextButton
public void hideNextButton()Hide the "Next" button. -
hideFinishButton
public void hideFinishButton()Hide the "Finish" button. -
hideCancelButton
public void hideCancelButton()Hide the "Cancel" button. -
unhideBackButton
public void unhideBackButton()Unhide the "Back" button. -
unhideNextButton
public void unhideNextButton()Unhide the "Next" button. -
unhideFinishButton
public void unhideFinishButton()Unhide the "Finish" button. -
unhideCancelButton
public void unhideCancelButton()Unhide the "Cancel" button. -
setCancelLabel
Set the label on the "Cancel" button.- Parameters:
label
- Label to set.
-
setBackLabel
Set the label on the "Back" button.- Parameters:
label
- Label to set.
-
setFinishLabel
Set the label on the "Finish" button.- Parameters:
label
- Label to set.
-
setNextLabel
Set the label on the "Next" button.- Parameters:
label
- Label to set.
-
getStepLabel
Get a label for the step. If you provide a label, that will be displayed along with the step number.- Parameters:
step
- Step- Returns:
- Default implementation returns
null
so that no label is displayed.
-
getStepComponent
protected com.vaadin.flow.component.Component getStepComponent(int step) Get the component to be used for the respective step. (After creating your component, you may invoke one of these static methods to position the component if needed:align(Component, CSSGrid.Position)
,justify(Component, CSSGrid.Position)
,center(Component)
).- Parameters:
step
- Step- Returns:
- Component to be added. (Default implementation) returns
null
.
-
enter
protected void enter(int step) This method is invoked when you enter into this step.- Parameters:
step
- Step
-
back
protected void back(int step) This method is invoked when you go back to the previous step from this step.- Parameters:
step
- Step
-
complete
This method is invoked when you complete a step. (From the last step, you typically do the rest of the processing andView.close()
the view. If it raises any error or returnsfalse
, forward movement will be stopped.- Parameters:
step
- Step- Returns:
- True if the operation is successful.
- Throws:
Exception
- In case of any error.
-
commit
This method is invoked before invokingcomplete(int)
and if it raises any error or returnsfalse
, forward movement will be stopped.- Parameters:
step
- Step- Returns:
- True if the commit operation is successful.
- Throws:
Exception
- Any exception
-
cancel
public void cancel()This method will be invoked when "Cancel" button is pressed. The default behaviour is toView.abort()
the view. -
complete
public void complete()This method is invoked when the all steps are successfully completed. The default behaviour is closes the view by invokingView.close()
. -
justify
public static void justify(com.vaadin.flow.component.Component component, CSSGrid.Position position) Justify (horizontally) a component within the view's content area. (You may use this method from within yourgetStepComponent(int)
method to position your component).- Parameters:
component
- Componentposition
- Position
-
align
Align (vertically) a component within the view's content area. (You may use this method from within yourgetStepComponent(int)
method to position your component).- Parameters:
component
- Componentposition
- Position
-
center
public static void center(com.vaadin.flow.component.Component component) Center (horizontally and vertically) a component within the view's content area. (You may use this method from within yourgetStepComponent(int)
method to position your component).- Parameters:
component
- Component
-