You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Madhav Bhargava <Ma...@infosys.com> on 2007/03/14 08:26:50 UTC

Wierd behavior - valueChangeListener does not get called with selectOneMenu

Hi All,



Following is the JSP code:



<s:subForm id="subFormId">



x----- Cut ----x   



            <t:panelGrid columns="1" width="450px">

                        <t:selectOneMenu id="decline_value"
styleClass="selectOneMenu" onchange="document.forms[0].submit();return
false;"


value="#{physicianEConsultation.uiBean.declineValue}"


valueChangeListener="#{physicianEConsultation.detailsChanged}"
required="true">

                                    <f:selectItem itemLabel="--Select--"
itemValue=""/>

                                    <f:selectItems
value="#{physicianEConsultation.declineReasonList}"/>

                        </t:selectOneMenu>

                        <t:message for="decline_value"
styleClass="error"></t:message>

            </t:panelGrid>



x----- Cut ----x



</s:subForm>



In the above code we have a select one menu component. If the user
changes the selection then an onchange event is fired which will then
submit the form. Once the form is submitted then in process validations
phase the ValueChangeListener should be called.



Weird behavior:

With the above piece of code the value change listener does not get
called even when the user changes a selection in the drop down
component.

However if you add - immediate = "true" then the ValueChangeListener is
called.

I added <t:messages> to the JSP to check if there were any validation
errors which would cause the JSF to skip directly to the render response
phase. But there are no validation errors.



There is another observation that I made:

If I remove <t:subForm> component, then with the above code the
ValueChangeListener is called as expected.



Is this a problem with <t:subForm> component?





Regards,

Madhav



**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

Re: Migrate from a:href to commandLink

Posted by Simon Kitching <si...@rhe.co.nz>.
Why not? The h:commandLink tag renders an html <a> tag. It doesn't 
actually use the normal <a> behaviour; instead it attaches javascript to 
the onclick of the anchor that causes a form submit and suppresses the 
normal result of clicking on the link. However because the html tag *is* 
an <a>, css should be able to use the hover pseudo-attribute on it.

Am I missing something here?

Kevin Gutch wrote:
> Oh yes. I believe I could do that but it does not really solve the hover 
> issue. Does it?
> 
> 
> 
> Simon Kitching wrote:
>> Kevin Gutch wrote:
>>> I have a html link styled with CSS (see below).
>>>
>>> .a#j {display:block; width:105px; height:0; padding-top:115px; 
>>> overflow:hidden; position:absolute; left:5px; top:47px; 
>>> background:transparent 
>>> url(#{facesContext.externalContext.requestContextPath}/images/j.jpg) 
>>> no-repeat 340px 200px;}
>>> * html a#j {height:120px; he\ight:0;}
>>> a#j:hover {background-position: 0 0; overflow:visible;}
>>>
>>> I want to replace the <a/> with an commandLink and maintain the 
>>> style. However, just switching out the tag breaks the style. I can 
>>> add the style to inline to the commandLink by adding the  style 
>>> attribute. However, I am not sure how to add the hover style?
>>
>> You mention "inline style" on the commandLink. Have you considered 
>> using the "styleClass" attribute to assign a css *class* rather than 
>> an inline style?
>>
> 


Re: Migrate from a:href to commandLink

Posted by Kevin Gutch <kg...@protechemail.com>.
Oh yes. I believe I could do that but it does not really solve the hover 
issue. Does it?



Simon Kitching wrote:
> Kevin Gutch wrote:
>> I have a html link styled with CSS (see below).
>>
>> .a#j {display:block; width:105px; height:0; padding-top:115px; 
>> overflow:hidden; position:absolute; left:5px; top:47px; 
>> background:transparent 
>> url(#{facesContext.externalContext.requestContextPath}/images/j.jpg) 
>> no-repeat 340px 200px;}
>> * html a#j {height:120px; he\ight:0;}
>> a#j:hover {background-position: 0 0; overflow:visible;}
>>
>> I want to replace the <a/> with an commandLink and maintain the 
>> style. However, just switching out the tag breaks the style. I can 
>> add the style to inline to the commandLink by adding the  style 
>> attribute. However, I am not sure how to add the hover style?
>
> You mention "inline style" on the commandLink. Have you considered 
> using the "styleClass" attribute to assign a css *class* rather than 
> an inline style?
>

-- 

*Kevin Gutch*
*Protech Products, Inc*.
407.328.5300, ext. 102
407.328.5250 (fax)



Re: Migrate from a:href to commandLink

Posted by Simon Kitching <si...@rhe.co.nz>.
Kevin Gutch wrote:
> I have a html link styled with CSS (see below).
> 
> .a#j {display:block; width:105px; height:0; padding-top:115px; 
> overflow:hidden; position:absolute; left:5px; top:47px; 
> background:transparent 
> url(#{facesContext.externalContext.requestContextPath}/images/j.jpg) 
> no-repeat 340px 200px;}
> * html a#j {height:120px; he\ight:0;}
> a#j:hover {background-position: 0 0; overflow:visible;}
> 
> I want to replace the <a/> with an commandLink and maintain the style. 
> However, just switching out the tag breaks the style. I can add the 
> style to inline to the commandLink by adding the  style attribute. 
> However, I am not sure how to add the hover style?

You mention "inline style" on the commandLink. Have you considered using 
the "styleClass" attribute to assign a css *class* rather than an inline 
style?

Migrate from a:href to commandLink

Posted by Kevin Gutch <kg...@protechemail.com>.
I have a html link styled with CSS (see below).

.a#j {display:block; width:105px; height:0; padding-top:115px; 
overflow:hidden; position:absolute; left:5px; top:47px; 
background:transparent 
url(#{facesContext.externalContext.requestContextPath}/images/j.jpg) 
no-repeat 340px 200px;}
* html a#j {height:120px; he\ight:0;}
a#j:hover {background-position: 0 0; overflow:visible;}

I want to replace the <a/> with an commandLink and maintain the style. 
However, just switching out the tag breaks the style. I can add the 
style to inline to the commandLink by adding the  style attribute. 
However, I am not sure how to add the hover style?

Any suggestions?

Thanks,

Kevin

Re: Wierd behavior - valueChangeListener does not get called with selectOneMenu

Posted by Madhav Bhargava <un...@gmail.com>.
Hi Mike,

Thanks for the reply. Yes you are right, i went thru the documenation again
right after i had posted this query . The javascript function that i need to
call is *<subFormID>_*submit()

If there is a subForm then only this requirement arises else you can simply
give onchange="submit()" and it will work.

I will check out the submitOnEvent component in sandbox.

Thanks again.
~madhav


On 3/17/07, Mike Kienenberger <mk...@gmail.com> wrote:
>
> If possible, I'd replace "onchange=document.forms[0].submit();return
> false;" with the submitOnEvent sandbox component.
>
> My guess is that you need to use the javascript documented here:
>
> http://myfaces.apache.org/sandbox/subForm.html
>
> I've had no issues with a subForm, a selectOneMenu, a submitOnEvent, and a
> commandButton triggering an action when an option is chosen from the menu.
>
>
> The other possiblity to investigate is if validation is failing for some
> other component on your page -- make sure you've got a t:messages component
> for debugging.
>
> On 3/14/07, Madhav Bhargava <Ma...@infosys.com> wrote:
> >
> >  Hi All,
> >
> >
> >
> > *Following is the JSP code:*
> >
> >
> >
> > <s:subForm id="subFormId">
> >
> >
> >
> > *x----- Cut ----x*
> >
> >
> >
> >             <t:panelGrid columns="1" width="450px">
> >
> >                         <t:selectOneMenu id="decline_value"
> > styleClass="selectOneMenu" onchange="document.forms[0].submit();return
> > false;"
> >
> >                                     value="#{
> > physicianEConsultation.uiBean.declineValue}"
> >
> >                                     valueChangeListener="#{
> > physicianEConsultation.detailsChanged}" required="true">
> >
> >                                     <f:selectItem itemLabel="--Select--"
> > itemValue=""/>
> >
> >                                     <f:selectItems value="#{
> > physicianEConsultation.declineReasonList}"/>
> >
> >                         </t:selectOneMenu>
> >
> >                         <t:message for="decline_value"
> > styleClass="error"></t:message>
> >
> >             </t:panelGrid>
> >
> >
> >
> > *x----- Cut ----x*
> >
> >
> >
> > </s:subForm>
> >
> >
> >
> > In the above code we have a select one menu component. If the user
> > changes the selection then an onchange event is fired which will then submit
> > the form. Once the form is submitted then in process validations phase the
> > ValueChangeListener should be called.
> >
> >
> >
> > *Weird behavior:*
> >
> > With the above piece of code the value change listener does not get
> > called even when the user changes a selection in the drop down component.
> >
> > However if you add – immediate = "true" then the ValueChangeListener is
> > called.
> >
> > I added <t:messages> to the JSP to check if there were any validation
> > errors which would cause the JSF to skip directly to the render response
> > phase. But there are no validation errors.
> >
> > * *
> >
> > *There is another observation that I made:*
> >
> > If I remove <t:subForm> component, then with the above code the
> > ValueChangeListener is called as expected.
> >
> >
> >
> > Is this a problem with <t:subForm> component?
> >
> >
> >
> >
> >
> > Regards,
> >
> > Madhav
> >   **************** CAUTION - Disclaimer *****************
> > This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> > solely for the use of the addressee(s). If you are not the intended
> > recipient, please notify the sender by e-mail and delete the original
> > message. Further, you are not to copy, disclose, or distribute this e-mail
> > or its contents to any other person and any such actions are unlawful. This
> > e-mail may contain viruses. Infosys has taken every reasonable precaution to
> > minimize this risk, but is not liable for any damage you may sustain as a
> > result of any virus in this e-mail. You should carry out your own virus
> > checks before opening the e-mail or attachment. Infosys reserves the right
> > to monitor and review the content of all messages sent to or from this
> > e-mail address. Messages sent to or from this e-mail address may be stored
> > on the Infosys e-mail system.
> > ***INFOSYS******** End of Disclaimer ********INFOSYS***
> >
>
>


-- 
When I tell the truth, it is not for the sake of convincing those who do not
know it, but for the sake of defending those that do

Re: Wierd behavior - valueChangeListener does not get called with selectOneMenu

Posted by Mike Kienenberger <mk...@gmail.com>.
If possible, I'd replace "onchange=document.forms[0].submit();return
false;"with the submitOnEvent sandbox component.

My guess is that you need to use the javascript documented here:

http://myfaces.apache.org/sandbox/subForm.html

I've had no issues with a subForm, a selectOneMenu, a submitOnEvent, and a
commandButton triggering an action when an option is chosen from the menu.


The other possiblity to investigate is if validation is failing for some
other component on your page -- make sure you've got a t:messages component
for debugging.

On 3/14/07, Madhav Bhargava <Ma...@infosys.com> wrote:
>
>  Hi All,
>
>
>
> *Following is the JSP code:*
>
>
>
> <s:subForm id="subFormId">
>
>
>
> *x----- Cut ----x*
>
>
>
>             <t:panelGrid columns="1" width="450px">
>
>                         <t:selectOneMenu id="decline_value"
> styleClass="selectOneMenu" onchange="document.forms[0].submit();return
> false;"
>
>                                     value="#{
> physicianEConsultation.uiBean.declineValue}"
>
>                                     valueChangeListener="#{
> physicianEConsultation.detailsChanged}" required="true">
>
>                                     <f:selectItem itemLabel="--Select--"
> itemValue=""/>
>
>                                     <f:selectItems value="#{
> physicianEConsultation.declineReasonList}"/>
>
>                         </t:selectOneMenu>
>
>                         <t:message for="decline_value"
> styleClass="error"></t:message>
>
>             </t:panelGrid>
>
>
>
> *x----- Cut ----x*
>
>
>
> </s:subForm>
>
>
>
> In the above code we have a select one menu component. If the user changes
> the selection then an onchange event is fired which will then submit the
> form. Once the form is submitted then in process validations phase the
> ValueChangeListener should be called.
>
>
>
> *Weird behavior:*
>
> With the above piece of code the value change listener does not get called
> even when the user changes a selection in the drop down component.
>
> However if you add – immediate = "true" then the ValueChangeListener is
> called.
>
> I added <t:messages> to the JSP to check if there were any validation
> errors which would cause the JSF to skip directly to the render response
> phase. But there are no validation errors.
>
> * *
>
> *There is another observation that I made:*
>
> If I remove <t:subForm> component, then with the above code the
> ValueChangeListener is called as expected.
>
>
>
> Is this a problem with <t:subForm> component?
>
>
>
>
>
> Regards,
>
> Madhav
>  **************** CAUTION - Disclaimer *****************
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended
> solely for the use of the addressee(s). If you are not the intended
> recipient, please notify the sender by e-mail and delete the original
> message. Further, you are not to copy, disclose, or distribute this e-mail
> or its contents to any other person and any such actions are unlawful. This
> e-mail may contain viruses. Infosys has taken every reasonable precaution to
> minimize this risk, but is not liable for any damage you may sustain as a
> result of any virus in this e-mail. You should carry out your own virus
> checks before opening the e-mail or attachment. Infosys reserves the right
> to monitor and review the content of all messages sent to or from this
> e-mail address. Messages sent to or from this e-mail address may be stored
> on the Infosys e-mail system.
> ***INFOSYS******** End of Disclaimer ********INFOSYS***
>