-
1. Re: Full usage of ComboBox
ilya40umov Dec 24, 2010 4:34 PM (in response to olasamuel)So you want a user to select one of comboBox items and then show him some specific form based on the selected item. Does user have to press a button to submit his choise? If so you can use a4j:include & ajax navigation in order to reRender page partialy. Does it fit for you?
-
2. Re: Full usage of ComboBox
olasamuel Dec 24, 2010 8:45 PM (in response to ilya40umov)Thank you for your response Ilya. However, The user does not need to press the button after selecting the button. The moment the user selects his choice the form is displayed and after filling the form that is being displayed then he can press a submit button to submit the form. Any direction? Thank you
-
3. Re: Full usage of ComboBox
ilya40umov Dec 25, 2010 2:04 AM (in response to olasamuel)1. use a4j support like in http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/a4j_support.html
2. add your forms into a wrapper like the following
<h:panelGroup id="wrap">
<h:form id="form1" rendered="#{el1}"/>
<h:form id="form2" rendered="#{el2}"/>
</h:panelGroup>
3. reRender wrap element on change event
WARN: #{elX} must still be true when a user sumbits formX otherwice JSF ignores a submit of formX
-
4. Re: Full usage of ComboBox
ilya40umov Dec 26, 2010 11:09 AM (in response to ilya40umov)This article http://community.jboss.org/wiki/CommonAjaxRequestsProblems could be very usefull for you
-
5. Re: Full usage of ComboBox
olasamuel Jan 4, 2011 9:22 AM (in response to ilya40umov)Hi,
I am still having problem implementing this. Can someone please show me an example of how this has been done before or send me the link may be this could be useful. Thank you
-
6. Re: Full usage of ComboBox
ilya40umov Jan 4, 2011 9:40 AM (in response to olasamuel)Could you post code(jsf page + bean) which you have now and then I can try to help you.
-
7. Re: Full usage of ComboBox
olasamuel Jan 5, 2011 11:06 AM (in response to ilya40umov)Ilya Sorokoumov wrote:
Could you post code(jsf page + bean) which you have now and then I can try to help you.
Please find attached the codes (JSF only) for the app. The main page is service configuration and what I am planing to do is that I want the content of the other pages be shown in service configuration depending on what a user selects from the comboBox in serviceConfiguration. Thanks for your help.
-
servicesSMS.xhtml.zip 947 bytes
-
serviceKeyword.xhtml.zip 1.1 KB
-
serviceconfiguration.xhtml.zip 858 bytes
-
-
8. Re: Full usage of ComboBox
ilya40umov Jan 5, 2011 4:11 PM (in response to olasamuel)I guess that you can do it in the following way:
1) add valueChangeListener to comboBox in order to handle a selection event
2) use ui:include into your rich:panel where you want to have different content
3) use attribute src of ui:include like this src="#{yourBean.somePath}". somePath should be changed in your valueChangeListener when user selects some option in comboBox.
4) You should reRender your rich:panel when comboBox value is changed
P.S. if ui:include won't work try a4j:include instead. But try ui:include before a4j because there may be some another issues with a4j:include.
P.S.S. Let me know about how it goes
Regards,
Ilya.
-
9. Re: Full usage of ComboBox
olasamuel Jan 11, 2011 5:16 AM (in response to ilya40umov)Hi llya,
I have followed the step you advised that I should follow but all to no avail. I went as far as tried different solution of the same way but still I can only get my comboBox to fetch the value but cannot display the pages as I want. I have therefore, attached my code to help see what I am doing wrong. I will be much grateful if anyone can tell me what I am doing wrong.
Attach is my codes. The (needed1 and needed2).txt are the backups of various BB codes that I used before I used tha ValuchangedBean.Java.
Someone please help.
-
ValueChangedBean.java.zip 755 bytes
-
serviceSms.xhtml.zip 939 bytes
-
serviceKeyword.xhtml.zip 1.1 KB
-
serviceConfiguration.xhtml.zip 934 bytes
-
serviceC3to.xhtml.zip 941 bytes
-
needed2.txt.zip 958 bytes
-
needed1.txt.zip 977 bytes
-
-
10. Re: Full usage of ComboBox
ilya40umov Jan 11, 2011 6:01 AM (in response to olasamuel)Hi Olalekan,
I looked into your code and I have several suggestions for you:
1) Do not use/try something if you are not sure that it's possible. Try to use code from demos/blog posts etc. but do not combine them because you will never find a mistake especially if there are a lot of them in your code at the same time.
2) Try to debug your code by using all possible mechanisms (System.out.println, rich:messages, look at server log files, firebug etc.)
3) Revise your knowledge about JSF. Read articles about actions/listeners/validators etc.
4) If you are using some RF component make sure that you understand how it works. Look at RF online documentaion / demo for the details.
5) A solving of every complicated issue consists of solving several smaller issues. Try to split your problem to pieces .
My solution follows below and it works fine
package test;
import java.io.Serializable;
public class TestBean implements Serializable {
private static final long serialVersionUID = 1L;
private String state = "";
public void valueChangeListener(javax.faces.event.ValueChangeEvent e) {
state = (String) e.getNewValue();
}
public void setState(String state) {
this.state = state;
}
public String getState() {
return state;
}
}
faces-config.xml:
<managed-bean>
<managed-bean-name>testBean</managed-bean-name>
<managed-bean-class>test.TestBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
xhtml page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.og/TR/xhtml1/DTD/xhtml-transitionl.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<head>
<title>Test</title>
</head>
<body>
<a4j:keepAlive beanName="testBean"></a4j:keepAlive>
<h:form>
<rich:comboBox value="#{testBean.state}" valueChangeListener="#{testBean.valueChangeListener}">
<f:selectItem itemValue=""/>
<f:selectItem itemValue="1"/>
<f:selectItem itemValue="2"/>
<f:selectItem itemValue="3"/>
<a4j:support event="onchange" reRender="wrap1,wrap2,wrap3"/>
</rich:comboBox>
</h:form>
<h:panelGroup id="wrap1">
<h:panelGroup rendered="#{testBean.state == '1'}">
11111111111
</h:panelGroup>
</h:panelGroup>
<h:panelGroup id="wrap2">
<h:panelGroup rendered="#{testBean.state == '2'}">
22222222222
</h:panelGroup>
</h:panelGroup>
<h:panelGroup id="wrap3">
<h:panelGroup rendered="#{testBean.state == '3'}">
33333333333
</h:panelGroup>
</h:panelGroup>
</body>
</html>
Regards,
Ilya.
-
11. Re: Full usage of ComboBox
olasamuel Jan 12, 2011 4:07 AM (in response to ilya40umov)Thanks a lot for your help and the detailed advice Ilya. However, I must say that it is difficult to implement the solution that you have advised. The reason being the fact that anytime I edit the faces-config.xml. My JBoss starts running in a loop and it will not allow my apps to be deployed on the server. I have had this problem with pages.xml before and till this moment I have not known the reason why this has to be so. Then what I did was to go inside pages.xml after shutting down eclipse and edit it. I did the same to faces-config.xml and it is not working out for me. I guess that is one of the price one has to pay for using open source system. Any idea as to how to go around this?
Regards
-
12. Re: Full usage of ComboBox
ilya40umov Jan 12, 2011 4:32 AM (in response to olasamuel)I'm not an expert in Seam so can't tell you a lot. Do you need to define you beans in faces-config.xml if you can use @Name? I just showed my implementation and it works on Jboss 5.1/JSF1.2/Facelets 1.1.15-B1/RichFaces 3.3.3Final. If you use another environment you should adapt my solution to it. May be you should write about your problem(with Jboss & Eclipse) on some other forums(Jboss server/Eclipse etc.). B.T.W what environment are you using?
-
13. Re: Full usage of ComboBox
olasamuel Jan 12, 2011 4:37 AM (in response to ilya40umov)I am using Eclipse/JBoss and I am solely developing seam apps. However, I do not need to define my beans in faces-config.xml if I can use at name but I think I should first implement it the way it is before I start making changes. Thank you
-
14. Re: Full usage of ComboBox
olasamuel Jan 12, 2011 9:58 AM (in response to olasamuel)Hi Ilya,
Thank you for your prompt help. I have re looked at the code but I found out that the form can only be displayed with the h:selectOneMenu as oppose to rich:comboBox. Thus far it is work but the problem that I am having now is that my webform that I want to display is not display. But when I change the value in the selectOneMenu, it fires the 11111, 22222, 33333 but it does not display my form and what I get is "WARNING [renderkit] 'for' attribute cannot be null" from my JBoss console. Can you or anyone tell me what I am doing wrong? Please see attached my code.
serviceConfiguration.xhtml is the main body and the rest *.xhtml are the forms that I want to rendere.
Thank you
-
ValueChanged.java.zip 273 bytes
-
ValuChangeBean.Java.zip 609 bytes
-
serviceSms.xhtml.zip 939 bytes
-
serviceKeyword.xhtml.zip 1.1 KB
-
serviceConfiguration.xhtml.zip 859 bytes
-
serviceC3to.xhtml.zip 941 bytes
-