Someone correct me if I'm wrong, but you can retrieve a component from the
current view root with the following code:
<code>
FacesContext fc = FacesContext.getCurrentInstance();
UIViewRoot view = fc.getViewRoot();
view.findComponent("yourComponentId");
</code>
According to the docs for the 'findComponent' method, this will search within a
naming container (form) as far down the tree as necessary until it reaches
another naming container (subform) which it will not search in....so if you're
using subform's, search for the subform first and then use the subform
component to search for the component you're looking for.
Nate Perkins
480-441-3667
[EMAIL PROTECTED]
This email message is for the sole use of the intended recipient(s) and may
contain GDC4S
confidential or privileged information. Any unauthorized review, use,
disclosure or distribution
is prohibited. If you are not an intended recipient, please contact the sender
by reply email and
destroy all copies of the original message.
________________________________
From: Stéphane Poirier [mailto:[EMAIL PROTECTED]
Sent: Friday, June 08, 2007 6:38 AM
To: MyFaces Discussion
Subject: Re: [Trinidad] Data-display synchronisaion problem
Thanks for answering! Sounds like a good solution but I have a little
problem... I must not use non-Serializable global variables in my bean (for
clustering). I'm just storing the "Object" element corresponding to the
selected value of the combobox. Is there another way to do this ? To retrieve
the CoreSelectOneChoice with Java code for example?
On 6/7/07, Adam Winer <[EMAIL PROTECTED]> wrote:
This has nothing to do with the phaseListener - and in fact,
you should not be referring to the trinidadinternal listener in
your faces-config.xml. (It's automatically registered, so you're
double-registering it.)
The issue is that there's a pending "local value" for each
component when Update Model runs. That local value
is still pending when setMasterSelectedValue() is called,
and will be pushed in.
To work around this, call resetValue() on the child
CoreSelectOneChoice in your updateComboBoxes() code.
-- Adam
On 6/7/07, Stéphane Poirier <[EMAIL PROTECTED]> wrote:
Hi,
I have a problem synchronizing my data with the visual result.
I want to implement 2 dependent comboBoxes (tr:selectOneChoice) using
partialTriggers. The components get their value from respective variables of a
backingBean. The problem is that when changing the master combo (which updates
the child combo when is Setter is called), the child combo refreshes but tries
to select the item it was supposed to select the time before. I noticed that
the master combo's Setter is called after the child combo's 1st Getter (so this
1st getter has unsynchronized data).
Anyone knows what's going on and how to solve this? This sounds
like a PhaseListener issue or a bad use of the technology. Thanks in advance!
Here's some code:
JSP Code:
<tr:selectOneChoice
value="#{Bean.masterSelectedValue}" autoSubmit="true" id="master">
<f:selectItems value="#{
Bean.masterList}" />
</tr:selectOneChoice>
<tr:selectOneChoice
value="#{Bean.childSelectedValue}" partialTriggers="master">
<f:selectItems
value="#{Bean.childList}" />
</tr:selectOneChoice>
Bean Code :
private ArrayList<SelectItem> masterList;
private Object masterSelectedValue;
private ArrayList<SelectItem> childList;
private Object childSelectedValue;
...
public void setMasterSelectedValue(Object value) throws
Exception
{
this.masterSelectedValue = value;
updateComboBoxes(); //Code that updates the child
combobox value and selected item
}
Faces-config listener
<lifecycle>
<phase-listener>
org.apache.myfaces.trinidadinternal.context.TrinidadPhaseListener
</phase-listener>
</lifecycle>