Generating a Cancel Button

Over in the JHeadstart Discussion Forum, Raghu asks how he can add a cancel button to the transactional pages generated with JHeadstart. Since this a recurring question, I will answer it here.

The Cancel button should appear in all pages where you can insert, update or delete data. In short, all pages where a Save button is present to commit the changes. So, the easiest way to add a Cancel button to your transactional pages, is by modifying the Save button template, and add a Cancel button inside this template that appears side-by-side with the Save button. Here are the steps:


  • Make a copy of saveButton.vm, name it something like SaveAndCancelButton.vm.

  • Add the Cancel button as follows to this template:
#if (!$JHS.page.pageReadOnly)

  <af:commandButton text="#CANCEL_LABEL()" immediate="true"
      actionListener="#{bindings.Rollback.execute}"
      #JHS_PROP("rendered" $JHS.page.saveButtonRenderedExpression)
      action="Start${JHS.current.group.baseGroup.name}"   
      onclick="alertForChanges();"
      id="${JHS.current.group.name}CancelButton">
    <f:actionListener type="oracle.jheadstart.controller.jsf.listener.ResetBreadcrumbStackActionListener"/>
    <af:resetActionListener/>
  </af:commandButton>
               

  <af:commandButton actionListener="#{bindings.Commit.execute}"
      action="Commit" #VALIDATE_FORM()
      #JHS_PROP("rendered" $JHS.page.saveButtonRenderedExpression)        
      textAndAccessKey="${JHS.nls(${JHS.current.group.displayTitleSingular},
       "SAVE_BUTTON_LABEL_${JHS.current.group.name}", "SAVE_BUTTON_LABEL" )}"
                  id="${JHS.current.group.name}SaveButton">
   <af:resetActionListener/>
  </af:commandButton>         
#end



  • Open the Application Definition Editor, select the top-level Service node, go to the Templates tab, and set the SAVE_BUTTON template to the name of your custom "SaveAndCancelButton" template.
  • Generate your application
That's all, in 1 minute you added a cancel button to all your transactional pages. Long live 100% generation!

Note that in the example the action property is set to go to the first page within the group. You can easily change this if you like. For, example, you can use the first custom property of a group which can be set in the Application Definition Editor, to specify the navigation action for the Cancel button by setting the action property to "${JHS.current.group.property1}"

Comments:

Excellent. Thanks For Posting in JHeadStart Blog.

Posted by Rajagopalan Raghuraman on April 10, 2007 at 09:52 PM PDT #

Dear Steven, I think that the "onclick" property in the Cancel af:commandButton tag must change to: onclick="return alertForChanges();", in order to work the "alertForChanges" confirm dialog Cancel button correctly. Have a look at it! Thanks a lot!

Posted by Stamatis Voutsiadis on September 25, 2007 at 11:06 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Java EE Consultants - JHeadstart, ADF, JSF

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today