Skip to main content

f:ajax render wrong

3 replies [Last post]
alex1712
Offline
Joined: 2010-06-11
Points: 0

Hello,

I would like to ask you for help :).

I have a little ajax call wich just should make a new object in a list of elements and after render again the form.

When I call to the method I can make the process without problems and I see in the variables that I create the new object. But when everything it is done and the application paint the results, the results are not updated. It paints the data from the before call.

For example, if I pushed the button two times, the first time don't paint anything new and the second time paint the first object created.

This is my code:

--XHTML--

--XHTML--

--BEAN--

@Inject
SessionBean sessionBean;
@Inject
@InjectProfile
Profile profile;

public void newContactInformationPhone() {
profile.addContactInformation(new ContactInformation(ContactInformationVisibility.PRIVAT, ContactInformationKind.PHONE, ContactInformationType.WORK, null));
}
--BEAN--

Thank you very much in advance :)

Alex

Message was edited by: alex1712

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joel Weight

I'm not sure how c:forEach plays with f:ajax. I would replace the forEach
with ui:repeat.

Joel

On Fri, Jun 11, 2010 at 10:50 AM, wrote:

> Hello,
>
> I would like to ask you for help :).
>
> I have a little ajax call wich just should make a new object in a list of
> elements and after render again the form.
>
> When I call to the method I can make the process without problems and I see
> in the variables that I create the new object. But when everything it is
> done and the application paint the results, the results are not updated. It
> paints the data from the before call.
>
> For example, if I pushed the button two times, the first time don't paint
> anything new and the second time paint the first object created.
>
> This is my code:
>
> --XHTML--
>
> > columnClasses="reg_col_label,reg_col,reg_col,reg_col_small_wide">
> > items="${sessionBean.profile.contactInformationsPhone}">
>
> > itemValue="PHONE" />
> > itemValue="MOBILEPHONE" />
>

>
>
> > itemValue="PRIVAT" />
> > itemValue="PUBLIC" />
>

>

>
>
> > image="/p/images/add_button_original.png"
> actionListener="#{profileEditBean.newContactInformationPhone}">
> > render="phoneEditForm :phoneOutputForm"/>
>
>
> > onclick="javascript:slide('#phoneOutput');slide('#phoneEdit');"/>
>
> > actionListener="#{profileEditBean.save}"/>
>
>

>

>
> --XHTML--
>
> --BEAN--
> public void newContactInformationPhone() {
> profile.addContactInformation(new
> ContactInformation(ContactInformationVisibility.PRIVAT,
> ContactInformationKind.PHONE, ContactInformationType.WORK, null));
> }
> --BEAN--
>
>
> Thank you very much in advance :)
>
> Alex
> [Message sent by forum member 'alex1712']
>
> http://forums.java.net/jive/thread.jspa?messageID=473925
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>
[att1.html]

alex1712
Offline
Joined: 2010-06-11
Points: 0

Thank you very much, the ajax work fine with ui:repeat.

But now, it writes all data in a single column. Do I have to make the table by myself?

Thank you again :)

mpscholz
Offline
Joined: 2003-06-12
Points: 0

ui:repeat does not render a HTML table by default.
It just display the child elements one by one, without an "in-built" layout, so you have to provide the layouting by yourself; alternatively, you could use list components of JSF libraries like PrimeFaces (http://www.primefaces.org:8080/prime-showcase/ui/dataListHome.jsf).

If you need a HTML table, use h:dataTable.