I am using richfaces 4.1.0M2 with JSF2.0 and I have a PickList and what I want is that when someone selects (mouse click) an item in the left list, some component in the form is updated based on what is clicked. I have managed to trigger an event in the bean whan some one clicks on an item. The code to achieve the trigger is
<rich:pickList showButtonsLabel="false" value="#{groupBean.pickListResult}"
listHeight="100" converter="#{groupBean.converter}">
<a4j:ajax event="click" render="userlist" limitRender="true" listener="#{groupBean.updateGroupMembers}"/>
<f:selectItems value="#{groupBean.leftPickList}" />
</rich:pickList>
But I am not able to get the value of SelectItem which was clicked. Any idea how I can do that. I read in the documentation that each item has three states associated with it in the PickList i.e common, selected, active. So is there a way to get these states in the bean. Any idea.
The selected value will be available in groupBean.pickListResult (on the server)
I Think you Should use onchange Event in <a:support>
ex: <a4j:ajax event="onchange" render="userlist" limitRender="true" />
Related
I want to get the selected value in the SelectOneRadio in Oracle ADF jsff.
The problem is that i dont want to refer each and every click to a ValueChangeListener.
That creates a lot of server load.
is there any way to get the value selected in the radio button and display it in an output text by partially updating it and all..
I have tried multiple Blogs all referring to use of BackingBean.
Thanks in advance
You can create a binding to that component, and get it's value within the same method where the bind is. For example:
<af:selectOneRadio value="#{bindings.Deptno.inputValue}" label="Select Department"
required="true" shortDesc="#{bindings.Deptno.hints.tooltip}"
id="soc1" autoSubmit="true" binding="#{managedBeanName.selectOneRadio}>
<f:selectItems value="#{bindings.Deptno.items}" id="si1"/>
and then the bean should look like this:
import oracle.adf.view.rich.component.rich.input.RichSelectOneRadio
public class ManagedBeanName{
private RichSelectOneRadio radio;
//getters/setters for 'radio' here
public void printValue(){
System.out.println(radio.getValue());
}
The last thing would be the call to this method each time YOU want to print/get the selected value.
A call to a ValueChangeListener should not overload the server.
Try
<af:selectOneRadio value="#{bean.aValue}" id="sor1" autoSubmit="true">
<f:selectItem itemLabel="Option1" itemValue="1"/>
<f:selectItem itemLabel="Option2" itemValue="2"/>
<f:selectItem itemLabel="Option3" itemValue="3"/>
</af:selectOneRadio>
<af:outputText value="#{bean.aValue}" partialTriggers="sor1"/>
No ValueChangeListener but still a trip on the server. You can't avoid that. ADF is based on JSF and this is the way the technology works.
I encountered with problem: in IE8 don't work event in f:ajax and don't update other components after change value.
<h:selectBooleanCheckbox id="someId"
value="#{someBean.showEmpty}"
title="#{i18n['button.showEmpty']}">
<f:ajax event="change"
listener="#{someBean.changeShowEmpty}"
execute=":someForm #form" render=":messages :someForm #form" />
</h:selectBooleanCheckbox>
In Chrome, Opera, Firefox - it works.
Thanks for the help.
That's indeed "expected" behaviour for MSIE. It will only work on 2nd change and forth, because MSIE thinks that the 1st click is in essence not a change. You should be listening on the click event instead. That's also exactly what the <f:ajax> already by default does for a <h:selectBooleanCheckbox>. Just remove the event attribute altogether.
<f:ajax listener="#{someBean.changeShowEmpty}"
execute=":someForm #form" render=":messages :someForm #form" />
The <f:ajax event> defaults to "valueChange" in UIInput components and defaults to "action" in UICommand components. In UIInput components which generate radio button or checkbox, it will then generate onclick. In other UIInput components (text fields, textarea, dropdowns, etc) it will generate onchange.
Unrelated to the concrete problem, an other <h:form> can not be processed in contrary to what you seem to think in execute attribute, simply because its values are not submitted along with the submit of the current form. But that's another story.
How can I bring the <p:selectOneMenu item values back while editing.Now it just showing 'Select One', and users have to select the desired one (or already submitted)again. How can I bring that?
try to remove the first f:selectItem of yours
<f:selectItem itemLabel="#{employeeView.employeeDTO.trMode}" itemValue='#{employeeView.employeeDTO.transportMode}' />
the value attribute of the <p:selectOneMenu tag will hold the selected value...
and by the way , here are several examples of it : p:selectOneMenu
I have a an a4j:outputPanel that is rendered based on some boolean condition:
<a4j:outputPanel id="someDisplayRegion" rendered="#{doc.ready && someClass.someBooleanMethod}">
// bunch of stuff //
</a4j:outputPanel>
Then on the same .xhtml page, I have a drop-down menu and selecting one of its options should reRender the above region:
<rich:dropDownMenu>
<f:facet name="label">
<a4j:commandLink styleClass="btn-pulldown">
<span><h:outputText value="Export"></h:outputText></span>
<span class="opener"></span>
</a4j:commandLink>
</f:facet>
<rich:menuItem submitMode="none">
<s:link
rendered="#{someOtherBooleanMethod}"
value="#exportDoc"
action="#{runSomething.exportDoc()}"
reRender="someDisplayRegion"
target="downloadfile"
><s:conversationId /></s:link>
</rich:menuItem>
</rich:dropDownMenu>
However, when I click on the menu item from the drop-down menu, it does not go into someClass.someBooleanMethod and thus, does not re-render someDisplayRegion. Am I doing something wrong?
Consider this point of the RichFaces documentation:
As with most Ajax frameworks, you should not attempt to append or
delete elements on a page using RichFaces Ajax, but should instead
replace them. As such, elements that are rendered conditionally should
not be targeted in the render attributes for Ajax controls. For
successful updates, an element with the same identifier as in the
response must exist on the page. If it is necessary to append code to
a page, include a placeholder for it (an empty element).
So add a wrapper around your outputPanel and target the wrapper in the reRender attribute.
<a4j:outputPanel id="wrapper">
<a4j:outputPanel id="someDisplayRegion" rendered="#{doc.ready && someClass.someBooleanMethod}">
// bunch of stuff //
</a4j:outputPanel>
</a4j:outputPanel>
<s:link reRender="wrapper" [...] />
s:link doesn't have reRender attribute, it's only available on RichFaces components.
rich:menuItem and s:link aren't the best of friends. (especially not in earlier version of RichFaces).
Is there a specific reason why you want to use s:link here ?
Putting the action and the reRender on the menuItem itself should work fine.
I don't understand why you think clicking on the menu item should go into someClass.someBooleanMethod and not into runSomething.exportDoc(). At what point are doc.ready and someClass.someBooleanMethod being set to true? You might put a debugging statement in your code that verifies these are being set to true. If they are set to true and your a4j:outputPanel is still not rendering then you have a problem. I use the s:link as you do here and it works, but I remember having to fiddle with it. Make sure the action fired in the s:link returns a String. "actions" have to return strings that can be used for navigation though in my case the page navigates to itself (like yours).
<rich:comboBox id="combo" width="100px"
value="#{bean.scenarioString}"
suggestionValues="#{bean.scenarios}">
</rich:comboBox>
<a4j:commandButton value="button" action="#{bean.function}"></a4j:commandButton>
When the button is clicked scenarioString is being setted to selected value. But I want to set the scenarioString when the user select the value from combobox. Is this possible ? also if I can call the function after the scenarioString setted. it will be very help full. I try to use a4j:support but sure I have no value to set... I don't know, will the scenarioString be setted when the form is submitted but I try to use combobox in a h:form and try to submit "onselect" but I could't do it.
Update: I realized that my rich:combobox is already in a h:form, the h:form is in a iu:composition template, that I am using it for the page that my combobox in it.
<a4j:support event="onselect" >
<f:setPropertyActionListener target="#{bean.scenarioString}}" value="..."/>
</a4j:support>
Techs:JSF 1.2 RichFaces 3.3.3