-
1. Re: JSF Custom Component and ajax4jsf problem
ilya_shaikovsky Dec 23, 2010 5:11 AM (in response to krbaburaj)at first do not update conditionally rendered component itself. use it's parent update instead.
-
2. Re: JSF Custom Component and ajax4jsf problem
krbaburaj Dec 24, 2010 4:52 AM (in response to ilya_shaikovsky)thanks Ilya for your reply....
update conditionally rendered component itself
The above line if u can make it a bit clear.. it will be more helpful
-
3. Re: JSF Custom Component and ajax4jsf problem
krbaburaj Dec 25, 2010 11:26 AM (in response to ilya_shaikovsky)Ilya Shaikovsky wrote:
at first do not update conditionally rendered component itself. use it's parent update instead.
I didnt understand .... please explain a bit more
-
4. Re: JSF Custom Component and ajax4jsf problem
ilya40umov Dec 25, 2010 2:20 PM (in response to krbaburaj)it means if your component(which you want to reRender) has an EL in rendered attribute. And you want it to apper/dissapper. You should use ID of its parent in reRender of your a4j:support. Like this
<h:someTag>
<a4j:support reRender="wrapID">
</h:someTag>
<h:panelGroup id="wrapID">
<h:someComponentYouWishToDisapper rendered="#{el}"/>
</h:panelGroup>
-
5. Re: JSF Custom Component and ajax4jsf problem
krbaburaj Dec 26, 2010 1:49 AM (in response to ilya40umov)Hi Ilya.
I have done exactly what you told. The war file i had attached contains all these details... its a small working test applpication
I was using panel grid as parent. I had tried it using panel group also, as shown below
<h:panelGrid border="0" columns="1">
<h:selectOneMenu id="organizationNameId" value="#{dateTest.value}">
<f:selectItems value="#{dateTest.nameItems}" />
<a4j:support ajaxSingle="true" event="onchange"
action="#{dateTest.handle }" reRender="x" />
</h:selectOneMenu>
</h:panelGrid>
<h:panelGroup id="x">
<a:inputTime id="startTimeId" rendered="#{dateTest.three}"
value="#{dateTest.time }"></a:inputTime>
<h:inputText rendered="#{dateTest.three }"></h:inputText>
</h:panelGroup>here you can see the rendered value of both my component and inputText is same. inputText is switching fine.. but my component failed..
Please help me, if i had to write anything more to my custom component for making it dynamically rendered
-
6. Re: JSF Custom Component and ajax4jsf problem
ilya40umov Dec 26, 2010 3:27 AM (in response to krbaburaj)1) look at this topic http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/a4j_support.html and try to use valueChangeListener instead of using action="#{dateTest.handle }"2) Show also code of DateTest bean1) look at this topic http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/a4j_support.html and try to use valueChangeListener instead of using action="#{dateTest.handle }"
2) Show also code of DateTest bean
-
7. Re: JSF Custom Component and ajax4jsf problem
krbaburaj Dec 26, 2010 3:50 AM (in response to ilya40umov)Hi Ilya,
I had debugged a bit more on this issue and the following are the result. this will help to diagnose the issue
1) I had given log on the setter method of the tag and component and the handle method of the bean
2) What i saw is ,On change
1) framework is first calling the setter method of the COMPONENT
2) Calling the handle method of BEAN
3) Calling the setter method of the TAG
3) So all time component is having the old value
4) Reloding is happing but with old values
5) That is why component is not repainting
Is this the problem with me(I know it is because of me only, but i couldn't identify where exactly is the problem)
The following is my bean calss
package org.test;
import java.util.ArrayList;
import java.util.List;import javax.faces.model.SelectItem;
public class DateTest {
private String time = "18:16:45";
private boolean one;
private boolean two;
private boolean three;
private int value;
public void setTime(String time) {
this.time = time;
}
public String getTime() {
return time;
}
public String add() {
System.out.println("-----------> 1234 " + getTime().toString());
return "OK";
}
public void handle() {
if (value == 0) {
one = true;
two = false;
three = false;
}
else if (value == 1) {
one = false;
two = true;
three = false;
}
else if (value == 2) {
one = false;
two = false;
three = true;
}
System.out.println(one + " " + two + " " + three);
}
public List<SelectItem> getNameItems() {
List<SelectItem> items = new ArrayList<SelectItem>(1);
items.add(new SelectItem("0", "One"));
items.add(new SelectItem("1", "Two"));
items.add(new SelectItem("2", "Three"));
return items;
}
/**
* @return the one
*/
public boolean isOne() {
return one;
}
/**
* @param one
* the one to set
*/
public void setOne(boolean one) {
System.out.println("Set Bean One");
this.one = one;
}
/**
* @return the two
*/
public boolean isTwo() {
return two;
}
/**
* @param two
* the two to set
*/
public void setTwo(boolean two) {
System.out.println("Set Bean Two");
this.two = two;
}
/**
* @return the three
*/
public boolean isThree() {
return three;
}
/**
* @param three
* the three to set
*/
public void setThree(boolean three) {
System.out.println("Set Bean Three");
this.three = three;
}
/**
* @return the value
*/
public int getValue() {
return value;
}
/**
* @param value
* the value to set
*/
public void setValue(int value) {
this.value = value;
}
} -
8. Re: JSF Custom Component and ajax4jsf problem
ilya40umov Dec 26, 2010 4:18 AM (in response to krbaburaj)1) if you haven't tried the same without custom component you could try it with standart components only. It can help to determine where bug is(in custom components or the idea in general is wrong)
2) debug also get methods (I guess that JSF may not call isThree when it rerenders page)
3) try valueChangeListener for handling value change event
-
9. Re: JSF Custom Component and ajax4jsf problem
ilya40umov Dec 26, 2010 11:08 AM (in response to ilya40umov)I also suggest you to read this http://community.jboss.org/wiki/CommonAjaxRequestsProblems
-
10. Re: JSF Custom Component and ajax4jsf problem
krbaburaj Dec 26, 2010 12:35 PM (in response to ilya40umov)protected void setProperties(UIComponent component) {
super.setProperties(component);
UIInputTime uiTime = (UIInputTime) component;
System.out.println("SET Properties --> "+rendered);
if (rendered != null) {
System.out.println("Rendered ========= " + rendered);
if (TagLibUtil.isValueReference(rendered.toString())) {
TagLibUtil.setValueExpression(getFacesContext(), "rendered", rendered.toString(), uiTime, Boolean.class);
}
else {
uiTime.setRendered(rendered);
}
}}
Bean methods are calling on the change events.But the above method of TAG class is calling only once(at the very first time of rendering).
At the Onchange event setProperties method is not calling. Is that right flow. If i am ryte, once the setProperty method has called then only COMPONENT object gets the data from beans.
-
11. Re: JSF Custom Component and ajax4jsf problem
krbaburaj Dec 26, 2010 12:36 PM (in response to krbaburaj)What could be wrong, why the above setProperty method is not calling by the reRendering process
-
12. Re: JSF Custom Component and ajax4jsf problem
krbaburaj Dec 26, 2010 12:51 PM (in response to krbaburaj)Bean property is true ... but those value is not reaching the TAG and COMPONENTS. Why it is so. the value of the bean is reaching correctly. What is wrong with other properties.. For the past 2 weeks im fed with this 1.2 components. Development almost stopped becoz of this. Please help...
-
13. Re: JSF Custom Component and ajax4jsf problem
ilya40umov Dec 26, 2010 1:00 PM (in response to krbaburaj)Unfortunatly I've never tried to create complete JSF components. Facelets' ability to create custom components has been always enough for me. But I guess that there are guys here who can help you. You also can read this(it's about how to write JSF components with facelets) http://www.ibm.com/developerworks/java/library/j-facelets/
P.S. I think you can also try Richfaces CDK if you are not using it now.
-
14. Re: JSF Custom Component and ajax4jsf problem
ilya40umov Dec 26, 2010 1:01 PM (in response to ilya40umov)Sorry if I've disappointed you.