I created an InputText component dynamically. And then i created a valuexpression and bind it to component and i created an ajax behavior and added it to keyup event. the problem is after keyup event triggered, bounded veriable is not set. it is always null. I can see the value but it is not assigned yo bounded veriable.
I uploaded a video youtube. you can see the problem easyly. Link is under this line.
http://youtu.be/M_WXDiSp8pM
Alsoi i added codes to github. if you want, you can look.
https://github.com/kissoid/hata.git
`#Override`
`public void processAjaxBehavior(AjaxBehaviorEvent event) throws AbortProcessingException {`
`System.out.println(deger);`
`System.out.println(inputText.getValue());`
`System.out.println(event.getComponent().getAttributes().get("value"));`
`}`
`});`
`inputText.addClientBehavior("keyup", blurBehavior);`
`panelGrid.getChildren().add(inputText);`
`}
`<h:form id="form1">`
`<p:messages autoUpdate="true" />`
`<p:panelGrid id="deneme" columns="1">`
`<p:commandButton value="tıkla" ajax="false" actionListener="#{indexBean.islem}" update="#form" />`
`</p:panelGrid>`
`<p:outputLabel id="testLabel" value="#{deger1}" /> `
`</h:form>`
Related
This is my ManagedBean:
#Named(value = "mrBean")
#RequestScoped
public class MrBean {
public void laugh() {
System.out.println("HAHAHA");
}
public void prepareToLaugh() {
System.out.println("Drink water.");
}
}
And this is the working version of my commandButton:
<p:commandButton actionListener="#{mrBean.laugh}" widgetVar="laughtButton"
value="Laugh" oncomplete="laughButton.disable();" />
When I clicked the above button, I saw HAHAHA and the button is disabled. However, when I set the laughButton's disable attribute to true, the button does not work anymore:
<p:commandButton actionListener="#{mrBean.laugh}" widgetVar="laughtButton"
value="Laugh" disabled="true" oncomplete="laughButton.disable();" />
<p:commandButton actionListener="#{mrBean.prepareToLaugh}"
value="Prepare to laugh" oncomplete="laughButton.enable();" />
When I click the 2nd button, I saw Drink water and the 1st button is enabled. However, when I click on the 1st button, nothing happens.
I'd be very grateful if someone could give me an advice on how I should tackle this problem. I'm using PrimeFaces 3.0 RC2.
Like as with rendered attribute, JSF re-evaluates the disabled attribute in the server side during processing of the form submit as part of safeguard against tampered requests and like. You're however enabling/disabling it by JS without notifying the server side of the changes.
You need to ensure that the value of the disabled attribute evaluates false during the request whenever you intend the button to be enabled during processing of the form submit. For example, bind it to a boolean property of a view scoped bean which is set by the other button.
<h:commandButton disabled="#{bean.laughDisabled}" />
See also:
commandButton/commandLink/ajax action/listener method not invoked or input value not updated
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'm using Primefaces (version 3.0.1) p:tabView component, which displays dynamic number of tabs backed by a list in a model. Tabs inside TabView are closable. I'd like to remove list element associated with a tab by close event.
Here is my view:
<p:tabView id="tabView" var="iterator" value="#{bean.list}">
<p:ajax event="tabClose"
listener="#{bean.removeElement(iterator)}" process="#this" />
<p:tab id="tab" closable="true">
<h:outputText value="#{iterator.text}" />
</p:tab>
</p:tabView>
My bean handler:
public void removeElement(Element e) {
this.list.remove(e);
}
Element e is null in this case
I've also tried to use p:collector inside p:ajax element. There is example at primefaces.org showcase. According to it my event handler should look like
public void removeElement(TabCloseEvent event) {
// ...
}
But I don't know how can I get associated with tab list element.
All answers will be appreciated. Thanks in advance
public void removeElement(TabCloseEvent event) should be used, imo.
According to TabCloseEvent it has a method getData(). This should give you access to your model class. Disclaimer: I haven't used TabView the way you do yet, but it works this way for Primeface's Tree component (i.e. selection of a node). Could you post back your findings?
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 the following piece of code with a simple h:outputText pointing to a int and a p:commandLink to set a value:
<h:form id="f1">
<h:outputText id="text" value="#{testBean.index}"/>
<p:commandLink actionListener="#{testBean.test}" update="text">
<f:setPropertyActionListener target="#{testBean.index}" value="5" />
<h:graphicImage url="/images.png"/>
</p:commandLink>
</h:form>
The managed bean looks like this:
#javax.faces.bean.ManagedBean #ViewScoped
public class TestBean implements Serializable{
private int index; // getter/setter
#PostConstruct public void init() {
index = 0;log.log(Level.WARNING, "#PostConstruct");}
public void test(ActionEvent ae){
log.log(Level.WARNING, "Index: "+index);}
}
The bean is constructed correctly, and after the first click on the image the h:ouputText is updated to 5. But in my log message I only see Index: 0 during the first click on the image.
It's something similar like Jsf updates model value with old value, but I have the JSF #ManagedBean annotation.
Action listeners are invoked in the order they're definied in the view. You want to use action instead of actionListener. Even more, the action should in first place have been used to invoke a business action.
<p:commandLink action="#{testBean.test}" update="text">
<f:setPropertyActionListener target="#{testBean.index}" value="5" />
<h:graphicImage url="/images.png"/>
</p:commandLink>
See also:
Differences between action and actionListener
What is happening is that the test ActionEvent is getting fired before the request values have been applied.
To get a better understanding of the JSF phase lifecycle and when lifecycle events and ActionEvents fire, implement the Debug PhaseListener as specified in the following blog article.
http://balusc.blogspot.com/2006/09/debug-jsf-lifecycle.html
This should help you understand when request values are being applied, and when events are being fired.