Skip to main content

Very powerful yet simple JSF 2 with Ajax using render and renderd

in the jsf xhml 

<?xml version="1.0"?>

<f:view
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
>
    <h:head />
<h:body>
<h:form>
<h:selectOneRadio value="#{question.questionType}" >
       <f:selectItem itemValue="single" itemLabel="Single Choice" />
       <f:selectItem itemValue="multi" itemLabel="Multi Choice" />
       <f:ajax execute="@this" render="selectedType" />
</h:selectOneRadio>

 <h:panelGroup id="selectedType">

     <h:panelGroup layout="block" id="choices" rendered="#{question.questionType eq 'multi'}" >
   
    <table>
        <tr>
            <td>Choice Text: <h:inputText   /></td>
        </tr>
    </table>
     </h:panelGroup>
   
 </h:panelGroup>

</h:form>
</h:body>
</f:view>
---------------------------------------------------------------------------------------------------------------------
the backing bean code

@ManagedBean(name = "question")//Constants.QUESTION)
@RequestScoped
public class QuestionBean {

private String  questionType;

// getters and setters

}

Comments