When user clicks any commandButton
, then corresponding action is called in managed bean.
Is it possible to get this action name from @PostConstruct
method or from event listener method ?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
The button's name=value pair is by itself available as HTTP request parameter the usual way. Imagine that the generated HTML representation of the command button look like this
Then it's present as a request parameter with name
formId:buttonId
with a non-null value. JSF uses exactly this information during the Apply Request Values phase to determine if the button was pressed or not. This happens during thedecode()
method of the renderer associated with the button component, roughly as follows:Or when it concerns an ajax request, then the button's name is instead available as value of the
javax.faces.Source
request parameter.Either way, the
ActionEvent
is ultimately stored as a private field ofUIViewRoot
which is in no way available by a public API. So, unless you grab reflection and implementation specific hacks, it's end of story here.To determine the button pressed your best bet is to manually check the request parameter map the same way as JSF itself does.
Depending on the concrete functional requirement, which is not exactly clear from the question, an alternative may be to use
actionListener
or<f:actionListener>
on allUICommand
components of interest, or to use<action-listener>
infaces-config.xml
to register a global one. This will be invoked right before the realaction
is invoked.