0

I have following jsf-page:

 <ui:repeat value="#{seriesController.getSeries(userDataBean)}" var="title">
             <div>
                   <h:commandLink value="seriesDataBean.title = #{title}}">
                         <img width="250" src="/Test/image/cover_#{title}.png" alt="" />
                   </h:commandLink>
             </div>
 </ui:repeat>

The return value of .getSeries(...) is a collection of strings containing some titles.

What I try to do now is when the user is clicking on the image, the value of the field "title" (that is located in the bean-class "SeriesDataBean") should be set to #{title}.

But this does not work of course (I have typed it that way to communicate my goal). Is there any way to get this running?

Best regards

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
NHSH
  • 69
  • 7

1 Answers1

0

Thank God, I solved it':

@ManagedBean
@SessionScoped
public class TitleSelectorDataBean {

    /**
     * Creates a new instance of TitleSelectorDataBean
     */
    public TitleSelectorDataBean() {
    }

    private String selectedTitle;

    public String setTitle(String title) {
        this.selectedTitle = title;
        return "title";
    }

    public String getSelectedTitle() {
        return selectedTitle;
    }

    public void setSelectedTitle(String selectedTitle) {
        this.selectedTitle = selectedTitle;
    }

}

JSF-Page:

<h:form>
    <ui:repeat value="#{seriesController.getSeries(userDataBean)}" var="title">
        <div>
            <h:commandLink action="#{titleSelectorDataBean.setTitle(title)}">
                <img width="250" src="/Test/image/cover_#{title}.png" alt="" />
            </h:commandLink>
        </div>
    </ui:repeat>
</h:form>
NHSH
  • 69
  • 7