tags:

views:

174

answers:

2

hi are there any ways to call backing bean method in h:outputLink

thanks Sunny Mate

A: 

Use a h:commandLink instead.

<h:commandLink id="next" action="#{courseBean.submit}">
   <h:outputText value="Next Page »" />
</h:commandLink>

That generates a hyperlink that triggers an action when clicked.

ewernli
A: 

Just execute the code in the constructor of the request scoped backing bean associated with the page.

public class Bean {
    public Bean() {
        // Do your thing here.
    }
}
BalusC
Did you really meant to remove most of the text of your former answer? (maybe I didn't get the question properly, but I don't really get your answer neither)
ewernli
@ewernli: He basically want to execute some JSF bean code on a GET request. My previous answer involves passing parameters and `@PostConstruct`, but then I realized that he wasn't explicitly asking for that which might make my answer overcomplicated. Just doing it in the constructor of any request scoped bean which is referenced at least once in JSF page (e.g. `#{bean.xxx}`) is much easier.
BalusC
Ah ok. I understood the question differently :)
ewernli