<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
Related
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.
I have developed an JSF and richfaces based application, Here I want to know about a nice way to throw the warning to the user if described field (Rich:inplaceInput) is empty
I have created rich:extendedDataTable in which one of the column is this...
<rich:column width="120" id="col15" label="yardNo">
<f:facet name="header">
<h:outputText value="Yard Number"></h:outputText>
</f:facet>
<rich:inplaceInput value="#{r.runSlNo}" defaultLabel="Assign Manual Number"
inputWidth="90" showControls="true"/>
</rich:column>
and i have created a rich:contextMenu for displaying menu like this...
One commandbutton is also there for submitting the page.
I have two problems over here regarding rich:inplaceInput.
first,
I just dont want to allow the user to submit the page if the rich:InplaceInput value field is empty, rather throw an warning to fill it.
I know how to throw the error or warning before submitting the page.
Second, how can i avoid displaying contextMenu over rich:InplaceInput value but let it display at other 4 columns....
you can add required="true" to inplaceInput that way you wont submit the form... and you add h:messages bellow the table to display the error of required field or try adding h:message with for="id_of_the_rich:inplaceInput" and locate the h:message bellow the <rich:inplaceInput
i have a commandLink that has a graphicImage inside and i want to change some property
of the link to show that it is clicked.I could find no built-in property for that purpose.
Maybe some javascript or css code is required.Since i am not so good at those,i'd be glad if someone could guide me a way.Thanks
Here is the code of the link.
<p:commandLink title="Forward" update="growl"
actionListener="#{roombaBean.forward}">
<p:graphicImage value="images/but_forward.png" />
</p:commandLink>
Use onclick event of the commandLink to execute javascript.
Something like
<p:commandLink onclick="changeCSSInJavascript()" ...>
....
</p:commandLink>
You could add a style attribute to primefaces graphicImage and give it a string value from a bean. After the link it's clicked you could update that string value with: opacity:0.4:
<p:commandLink title="Forward" update="growl"
actionListener="#{roombaBean.forward}">
<p:graphicImage value="images/but_forward.png" style="#{myBean.myStringStyleValue}" />
</p:commandLink>
For IE8 and earlier use filter:alpha(opacity=40);
Anyway I don't really understand why do you want something like this? Don't you navigate away from the page? Why is it really matter that the image was clicked? Please, if you could give some more info, we could see if there is a better solution...
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" />
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).