action p:command button doesn’t set property into managed bean

I have an issue, I have a carousel, and I load dynamically some data into it, when I press into a carousel object it have to set a value into a manangedbean (CurrentSong) and show a dialog, now the dialog appear but the set property doesn’t work. why?

xhtml page:

<h:body style="background: url(../resources/images/knapsack_background_light.jpg); background-attachment:fixed;">
<div id="contentContainer" class="trans3d"> 
    <section id="carouselContainer" class="trans3d">
        <ui:repeat value="#{retrieve.mostPopularSongs}" var="carouselSelectedSong">
                            <figure id="item" class="carouselItem">
                <div class="itemInfo">
                    <h:commandButton id="selectedButton"
                                     action="#{currentSong.setSong(carouselSelectedSong)}"
                                     styleClass="btn"
                                     onclick="parent.showSongDialog();"
                                     style="
                                     background-image: url('#{carouselSelectedSong.coverPath}');
                                     background-size:100%;
                                     width:300px; 
                                     height:300px; 
                                     border: black;">
                        <f:ajax render="songDialogContent"/>
                    </h:commandButton>
                </div>
            </figure> 
        </ui:repeat>
    </section>
</div>

managed bean @ManagedBean @SessionScoped:

public class CurrentSong implements Serializable {
    @EJB
    private CustomerManagementLocal customerManagement;
    @EJB
    private SocialManagementLocal socialManagement;

    private Customer customer;
    private Song song;
    private String textComment;


    public CurrentSong() {
    }

    public Customer getCustomer() {
        return customer;
    }

    public Song getSong() {
        return song;
    }

    public void setSong(Song song) {
        System.out.println("----------------------------------------- current song: " + song.getTitle());
        this.song = song;
    }

    public void putLike () {
        putValutation(true);
    }

    public void putDislike () {
        putValutation(false);
    }

    public String getTextComment() {
        return textComment;
    }

    public void setTextComment(String textComment) {
        this.textComment = textComment;
    }

    public void putComment () {
        FacesContext context = FacesContext.getCurrentInstance();
        try {
            Comment newComment = new Comment(customer, new Date(), textComment, song);
            song.getCommentList().add(newComment);
            socialManagement.putComment(newComment);
            Notifier.notifyInfoMessage(context, Constants.INSERTION_COMMENT_SUCCESSFULLY);
            RequestContext requestContext = RequestContext.getCurrentInstance();
            requestContext.execute("clearTextComment();");
        } catch (CustomerNotFoundException ex) {
            Notifier.notifyErrorMessage(context, Constants.INTERNAL_ERROR);
        } catch (SongNotFoundException ex) {
            Notifier.notifyErrorMessage(context, Constants.INTERNAL_ERROR);
        }
    }

    private void putValutation (boolean valutation) {
        FacesContext context = FacesContext.getCurrentInstance();
        try {
            socialManagement.putValutation(new LikeValutation(customer, song, valutation, new Date()));
            Notifier.notifyInfoMessage(context, Constants.INSERTION_VALUTATION_SUCCESSFULLY);
        } catch (CustomerNotFoundException | SongNotFoundException ex) {
            Notifier.notifyErrorMessage(context, Constants.INTERNAL_ERROR);
        }
    } 

    @PostConstruct
    public void init() {
        customer = customerManagement.getCurrentCustomer();
    }

}

thanks!


Source: jsp

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.