> Now I tried the table editing example of DWR with
> dwr 2.0.1 (appfuse-jsf 2.0). It works well, but when I change the
>
> <input id="name"
>
> to
>
> <h:inputText id="name" (JSF)
>
> And the resulting HTML source prefix "j_id2:" with the JSF
> component.
>
> <input id="j_id2:name" name="j_id2:name" type="text" value="" />
> <input id="salary" type="text" size="20" />
> <input type="text" id="address" size="40" />
>
> The dwr.util.setValues(person) is not showing the name field value.
Ok, your problem here is with JSF's generated id/name attributes. Your
specified id="name" is prepended with a parent's id acting as naming
container.
As DWR's get/setValue[s] functions are purely client-side implementations,
and not dependent on your server-side framework, they can only consider
the resulting id/name and these are now different from the property names
in your person object.
Possible solutions:
1) Ask JSF not to rewrite the ids on these elements. I'm by no means a JSF
expert but I've seen this:
JSF 1.2: form prependId=false
Myfaces: input forceId=true
Check what your chosen JSF implementation can offer. It's probably
better to ask further questions on this subject in a JSF forum but it
would be nice if you can report back your findings here.
[Not rewriting the ids assume you don't have any other elements with
the same id that may interfere.]
2) Change the members of your person object to match the generated ids.
Probably not desired, but anyway:
person["j_id2:name"] = "Donald";
dwr.util.setValues(person);
3) Use setValue calls for every property instead of setValues:
dwr.util.setValue("j_id2:name", person.name);
... etc ...
4) Updating setValues() in 2.0.4 as it currently has almost the support
you need:
dwr.util.setValues(person, {prefix:"j_id2"});
The above will map
person.name -> id "j_id2.name"
and so forth. Note the separating dot instead of colon. We could add
a new option for configuring the separator character:
dwr.util.setValues(person, {prefix:"j_id2",separator:":"});
that would then map
person.name -> id "j_id2:name"
What does everybody think - is this the correct (and desired) way
of tackling this issue or is the JSF id thingie too complex to
handle properly anyway, and should be avoided?
Best regards
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail:
users-unsubscribe@...
For additional commands, e-mail:
users-help@...