webtier@glassfish.java.net

Re: [webtier] [JSF 2] Problem with CommandLinks in ajax-updated list

From: Lincoln Baxter, III <lincolnbaxter_at_gmail.com>
Date: Tue, 16 Mar 2010 20:22:38 -0400

Are you using custom JS code on your page? This can occur if there is a
script error, and JS stops executing. I ran into this bug once and it turned
out to be my bad JS code ;)

On Tue, Mar 16, 2010 at 11:48 AM, <webtier_at_javadesktop.org> wrote:

> Hi,
>
> I have some serious problems getting AJAX to work properly in my JSF2
> application. In that application, I have a list of comments for a photo.
> That list should be managed by either adding new entries via a form or
> removing existing entries by clicking a link next to that entry.
> Adding new entries works perfectly now, the list gets updated and
> everything's fine. What also works is removing one single entry.
>
> However, as soon as there has been an update to the list, be it either an
> add or a remove, the command links inside the list stop working properly.
> The ajax request still goes off, but the list returned is completely empty
> (JS debug revealed the returned result: <ul></ul>). Also, the action
> listener defined for the remove link is not fired on the server.
> If I add another entry, the list is refreshed correctly again (with the
> newly added entry), but, of course, as the action listener was not fired,
> the entry to be deleted before is still there. Completely refreshing the
> page shows up the page correctly and lets me delete one entry again before
> things start over.
> Here is the according code snippet:
>
> <h:panelGroup id="comments">
> <ul>
> <ui:repeat var="comment"
> value="#{ScopedPhoto.entry.comments}">
> <li>
> <h:form>
>
> <h3>#{comment.title}</h3>
>
> <p>#{comment.comment}</p>
> <p>(created
> @#{comment.created})
>
> <h:commandLink actionListener="#{comment.commitDelete}" value="X">
>
> <f:ajax render=":comments" execute="@form"/>
>
> </h:commandLink>
> </p>
> </h:form>
> </li>
> </ui:repeat>
> </ul>
> </h:panelGroup>
>
> <h:form>
>
> <h2>Add a comment</h2>
> <dl>
> <dt>Title:</dt>
> <dd>
> <h:inputText
> value="#{ScopedPhoto.entry.newComment.title}">
>
> </h:inputText>
> </dd>
> <dt>Comment:</dt>
> <dd>
> <h:inputText
> value="#{ScopedPhoto.entry.newComment.comment}" required="true">
>
> </h:inputText>
> </dd>
> </dl>
> <h:commandButton value="Add Comment"
> actionListener="#{ScopedPhoto.entry.newComment.commitInsert}" >
> <f:ajax render=":comments" execute="@form"/>
> </h:commandButton>
> </h:form>
>
>
> So I hope anyone has an idea how to fix this =)
> [Message sent by forum member 'jf7' (javafrog_at_javafrog.de)]
>
> http://forums.java.net/jive/thread.jspa?messageID=392185
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net
>
>


-- 
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"