autoComplete value not set to null

UI Components for JSF
vlkn
Posts: 26
Joined: 12 May 2010, 11:01

13 May 2010, 12:54

Hi!

I have a problem with autoComplete component. It's value is set to be bound to object, it has implemented and registered converter with the following snippet:

Code: Select all

<p:autoComplete id="catalogue"
	value="#{taskBean.catalogue}" var="catalog"
	itemValue="#{catalog}" itemLabel="#{catalog.label}"
	completeMethod="#{catalogueListBean.completeByQuery}"
	minQueryLength="2" maxResults="14">
	<f:converter converterId="catalogueConverter" />
</p:autoComplete>
It's working properly when value is set. But, if backing bean property is set, I just don't know how to set it's value back to null. If I delete contents from autoComplete field, it keeps previous value, it doesn't reset it to null. By logging in converter, I notice that component sends old value.

How can I set value back to null?

Thanks in advance.

vlkn
Posts: 26
Joined: 12 May 2010, 11:01

14 May 2010, 18:27

I know it must be something trivial, but I just can't find the answer. Anyone?

How can autoComplete set backing bean property value back to null?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

18 May 2010, 11:30

You submit the form after clearing the input right? Also can you post the code of your converter?

vlkn
Posts: 26
Joined: 12 May 2010, 11:01

18 May 2010, 11:47

Thank you for your reply.

Yes, I clear the input and it is empty and it stays empty until submit. After, due to value binding, it gets same value as before clearing input.

My converter's methods are:

Code: Select all

public Object getAsObject(FacesContext arg0, UIComponent component, String arg2) throws ConverterException {
	if (arg2 == null || arg2.length() == 0) {
		if (component instanceof EditableValueHolder) {
			((EditableValueHolder) component).setSubmittedValue(null);
		}
		return null;
	}
	String[] parsed = arg2.split(";");
	Catalogue catalogue = new Catalogue();
	catalogue.setId(Integer.parseInt(parsed[0]));
	catalogue.setLabel(parsed[1]);
	return catalogue;
}

public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) throws ConverterException {
	if (arg2 == null || !(arg2 instanceof Catalogue)) {
		return "";
	}
	return String.format("%s;%s", Integer.toString(((Catalogue)arg2).getId()), ((Catalogue)arg2).getLabel());
}

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

19 May 2010, 18:31

Can you replicate this case with showcase?

http://www.primefaces.org:8080/prime-sh ... tePojo.jsf

vlkn
Posts: 26
Joined: 12 May 2010, 11:01

19 May 2010, 19:08

Well, after trying to submit values on ShowCase, I noticed that there value is also remembered. If, for example, I enter there Messi and click on Submit button, message "Selected: Messi" is displayed. If I clear input and click on Submit once again, same message is displayed.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

24 May 2010, 13:08

Ok, now I replicated the issue as well, have you created a ticket in our issue tracker for this? If not I'd appreciate if you can and update this post with the issue number.

vlkn
Posts: 26
Joined: 12 May 2010, 11:01

24 May 2010, 13:56

cagatay.civici wrote:Ok, now I replicated the issue as well, have you created a ticket in our issue tracker for this? If not I'd appreciate if you can and update this post with the issue number.
Created a ticket with issue number 829: http://code.google.com/p/primefaces/iss ... ail?id=829

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

24 May 2010, 14:08

Awesome thanks. We'll take care of this.

vlkn
Posts: 26
Joined: 12 May 2010, 11:01

24 May 2010, 14:16

Looking forward to it.

By the way, you've done great job with PrimeFaces!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 45 guests