| |||||||
FRAMES NO FRAMES |
Use the webuijsf:button
tag to display an input
button in the rendered HTML page. The input button submits the
associated form when activated by the user. The corresponding
ActionEvent events then occur on the server.
<input>
button element
with a text label.primary
attribute is false by default, which renders a secondary button. The text
attribute is used to specify the characters
displayed on the buttons, which use a default button image set by the
theme. The escape
attribute, when set to false, causes an
HTML <button>
to be rendered instead of an <input>
element. The <button>
element, unlike the <input>
element, allows you to specify button text that will be interpreted as
HTML. For example if you wanted the button to say M&M, you would
have to specify M&M and set escape="false"
.
You can use the imageURL
attribute to specify a
different image for a button, or the icon
attribute
to specify a theme key to a button image. When you use these
attributes, the text
attribute is ignored, so your button
image must include any desired button text.
Note that the mini
attribute at one time rendered a
smaller button, but currently all buttons are the same size. The mini
attribute has no effect. However, you can use style
and styleClass
attributes to create a smaller button if desired.
The button component is the most commonly used component for
submitting
a page. By default, the button component creates a submit
button. However, you might want to use a button to go to another
page in the application. In this case, you should configure the button
with immediate="true"
and an actionExpression
that handles the navigation.
immediate="true"
and an actionListenerExpression
that updates the components. If you want a button to submit a page, you should not set immediate
,
and should set an actionExpression
and possibly an actionListenerExpression
.
The action should get information from the managed bean and
perform some business logic, and then determine what to show next on
the basis of the outcome of the business logic.
If you want the button to reset all the input component values on
the page, set the reset
attribute to true.
document.getElementById(id).setProps({disabled:
true})
.getProps() |
Use this function to get widget properties. Please see setProps()
function for a list of supported properties. |
refresh(execute) |
Use this function to
asynchronously refresh the component.
|
setProps(props) |
Use this function to change any of the following supported
properties:
|
When the component is manipulated client side, some functions may
publish event topics for custom AJAX implementations to listen for.
Using the Dojo event system, listen for the refresh event topic using:
<webuijsf:script>
var processEvents =
{
update: function(props) {
//
Do something...
}
}
// Subscribe to refresh event.
dojo.subscribe(webui.suntheme.widget.button.event.<eventname>.endTopic,
processEvents, "update");
</webuijsf:script>
The following events are supported.
webui.suntheme.widget.button.event.refresh.beginTopic | Event topic published before asynchronously refreshing the
component. Supported properties include:
|
webui.suntheme.widget.button.event.refresh.endTopic | Event topic published after asynchronously refreshing the
component. Supported properties include: See setProps() function.
|
<webuijsf:button id="button1" text="#{ButtonBean.text}"
actionExpression="#{ButtonBean.success}" primary="true" />
<webuijsf:button id="button1" text="#{ButtonBean.text}"
actionExpression="#{ButtonBean.success}" />
<webuijsf:button id="button1" text="#{ButtonBean.text}"
actionExpression="#{ButtonBean.success}" reset="true" />
<webuijsf:button id="button1" imageURL="#{ButtonBean.image}"
actionExpression="#{ButtonBean.success}" />
<webuijsf:radioButton id="rb1" name="rb1" label="Toggle Button Disabled" onClick="toggleDisabled()"/><webuijsf:button id="button1" text="My Button" />
<webuijsf:script>
function toggleDisabled() {
var domNode = document.getElementById("form1:button1
"); // Get button
return domNode.setProps({disabled: !domNode.getProps().disabled}); // Toggle disabled state
}
</webuijsf:script>
<webuijsf:radioButton id="rb1" name="rb1" label="Refresh Button" onClick="refreshButton()"/>
<webuijsf:button id="button1
" text="#{MyBean.text}"/>
<webuijsf:script>
function refreshButton() {
var domNode =
document.getElementById("form1:button1"); // Get button
return domNode.refresh(); //
Asynchronously refresh button
}
</webuijsf:script>
Note that the refresh function can optionally take a list of
elements
to execute. Thus, a comma-separated list of ids can be provided to
update components server-side: refresh("form1:id1,form2:id2,..."). When
no parameter is given, the refresh function acts as a reset.
That is, the component will be redrawn using values set
server-side, but not updated.<webuijsf:button id="button1
" text="#{MyBean.text}"/>
<webuijsf:textField id="field1" text="#{MyBean.text}" label="Change Button Text"
onKeyPress="setTimeout('refreshButton();', 0);"/> // Field used to asynchronously update text.
<webuijsf:script>
function
refreshButton
() {
var domNode =
document.getElementById("form1:button1"); // Get button
return
domNode.refresh("form1:field1"); // Asynchronously refresh while
submitting field value
}
</webuijsf:script>
Note that the refresh function can optionally take a list of
elements
to execute. Thus, a comma-separated list of ids can be provided to
update components server-side: refresh("form1:id1,form2:id2,...")Tag Information | |
Tag Class | com.sun.webui.jsf.component.ButtonTag |
TagExtraInfo Class | None |
Body Content | JSP |
Display Name | None |
Attributes | ||||
Name | Required | Request-time | Type | Description |
binding | false | false | java.lang.String | A ValueExpression that resolves to the UIComponent that corresponds to this tag. This attribute allows the Java bean that contains the UIComponent to manipulate the UIComponent, its properties, and its children. |
onDblClick | false | false | java.lang.String | Scripting code executed when a mouse double click occurs over this component. |
imageURL | false | false | java.lang.String | Resource path of an image to be displayed to create the visual appearance of
this button instead of the standard button image. Either the
|
onKeyPress | false | false | java.lang.String | Scripting code executed when the user presses and releases a key while the component has focus. |
reset | false | false | java.lang.String | Indicates that the button should be a HTML reset button. By default, this value is false and the button is created as a submit button. If the value is set to true, no action listener will be invoked. |
onFocus | false | false | java.lang.String | Scripting code executed when this component receives focus. An element receives focus when the user selects the element by pressing the tab key or clicking the mouse. |
escape | false | false | java.lang.String | Escape the html text so it won't be interpreted by the browser as HTML. When
the |
onKeyUp | false | false | java.lang.String | Scripting code executed when the user releases a key while the component has focus. |
onMouseUp | false | false | java.lang.String | Scripting code executed when the user releases a mouse button while the mouse pointer is on the component. |
styleClass | false | false | java.lang.String | CSS style class(es) to be applied to the outermost HTML element when this component is rendered. |
icon | false | false | java.lang.String | The identifier key of a theme image to be used for the button. |
style | false | false | java.lang.String | CSS style(s) to be applied to the outermost HTML element when this component is rendered. |
onClick | false | false | java.lang.String | Scripting code executed when a mouse click occurs over this component. |
mini | false | false | java.lang.String | Indicates that the button should be rendered using a different style than normal buttons. By default, a button that specifies the mini attribute looks the same as a normal button. You must set your own CSS style to render a mini button. |
onBlur | false | false | java.lang.String | Scripting code executed when this element loses focus. |
toolTip | false | false | java.lang.String | Sets the value of the title attribute for the HTML element. The specified text will display as a tooltip if the mouse cursor hovers over the HTML element. |
onMouseDown | false | false | java.lang.String | Scripting code executed when the user presses a mouse button while the mouse pointer is on the component. |
primary | false | false | java.lang.String | Indicates that the button is the most commonly used button within a group. |
disabled | false | false | java.lang.String | Indicates that activation of this component by the user is not currently permitted. In this component library, the disabled attribute also causes the button to be renderered using a particular style. |
onMouseOut | false | false | java.lang.String | Scripting code executed when the user moves the mouse pointer off this component. |
alt | false | false | java.lang.String | Alternative textual description of the image rendered by this component. The alt text can be used by screen readers and in tool tips, and when image display is turned off in the web browser. |
onMouseOver | false | false | java.lang.String | Scripting code executed when the user moves the mouse pointer into the boundary of this component. |
htmlTemplate | false | false | java.lang.String | Alternative HTML template to be used by this component. |
onMouseMove | false | false | java.lang.String | Scripting code executed when the user moves the mouse pointer while over the component. |
noTextPadding | false | false | java.lang.String | Indicates that padding should not be applied to the button text. By default, whitespace characters are padded to button text greater than or equal to 4 characters in length. If the value is set to true, no padding is applied. |
text | false | false | java.lang.String | Text to display on the button. Either the
|
visible | false | false | java.lang.String | Use the visible attribute to indicate whether the component should be viewable by the user in the rendered HTML page. If set to false, the HTML code for the component is present in the page, but the component is hidden with style attributes. By default, visible is set to true, so HTML for the component HTML is included and visible to the user. If the component is not visible, it can still be processed on subsequent form submissions because the HTML is present. |
onKeyDown | false | false | java.lang.String | Scripting code executed when the user presses down on a key while the component has focus. |
tabIndex | false | false | java.lang.String | Position of this element in the tabbing order of the current document. Tabbing order determines the sequence in which elements receive focus when the tab key is pressed. The value must be an integer between 0 and 32767. |
immediate | false | false | java.lang.String | Flag indicating that event handling for this component should be handled immediately (in Apply Request Values phase) rather than waiting until Invoke Application phase. |
actionExpression | false | false | java.lang.String | MethodExpression representing the application action to invoke when this component is activated by the user. The expression must evaluate to a either a String or a public method that takes no parameters, and returns a String (the logical outcome) which is passed to the NavigationHandler for this application. |
actionListenerExpression | false | false | java.lang.String | Use the actionListenerExpression attribute to cause the component to fire an event. The value must be an EL expression and it must evaluate to the name of a public method that takes an ActionEvent parameter and returns void. |
rendered | false | false | java.lang.String | Use the rendered attribute to indicate whether the HTML code for the component should be included in the rendered HTML page. If set to false, the rendered HTML page does not include the HTML for the component. If the component is not rendered, it is also not processed on any subsequent form submission. |
id | false | true | java.lang.String | No Description |
Variables | No Variables Defined. |
| |||||||
FRAMES NO FRAMES |