English 中文(简体)
JSF 2.0 <h:select OneRadio/> and <f:selectItem/> 我如何在届会期间通过选定的无线电台?
原标题:JSF 2.0 <h:selectOneRadio/> and <f:selectItem/> How can I pass the selected radio button in the session scoped?
  • 时间:2012-04-04 17:12:26
  •  标签:
  • jsf-2

我想在会议上通过所选的无线电塔顿值。 我的法典不会奏效。

这里的观点(Person.xhtml):

<h:form>

                        <h:selectOneRadio id="searchRadio" value="#{controller.radioButtonFlag}" valueChangeListener="#{controller.selectRadioButton}" >
                            <f:selectItem itemValue="fachid" itemLabel="#{msg.fachId}">
                                <f:attribute name="radioButtonField" value="fachid" />
                            </f:selectItem>
                            <f:selectItem itemValue="vngw" itemLabel="#{msg.VNGW}">
                                <f:attribute name="radioButtonField" value="vngw" />
                            </f:selectItem>
                        </h:selectOneRadio>

                        ...                     <h:commandButton action="#{controller.search}" value="#{msg.search}"></h:commandButton>

这里是经过管理的星号:

@ManagedBean @SessionScoped public class Controller { private String radioButtonField = "fachid"; private boolean VNGWSelected = false; public void selectRadioButton(ValueChangeEvent event){
    String select = (String) event.getComponent().getAttributes().get("radioButtonField");

    if(select.equals("vngw"))
        VNGWSelected = true;
} public String search() {... if(!VNGWSelected){logger.info("FachID RadioButton selected."); else{... logger.info("VNGW RadioButton selected."); ...} return "personsearch"; } ...} ... }

请允许我告诉我,我在这里做了什么错误?

提前感谢。

最佳回答

引证:

<h:selectOneRadio id="searchRadio" value="#{controller.select}" >
     <f:selectItem itemValue="fachid" itemLabel="#{msg.fachId}" />
     <f:selectItem itemValue="vngw" itemLabel="#{msg.VNGW}" />
</h:selectOneRadio>

<h:commandButton action="#{controller.search}" value="#{msg.search}"></h:commandButton>

我不相信你的神职人员是什么,或控制者的目标是什么,但最好使用归属感和获得者及设计者。

@ManagedBean 
@SessionScoped 
public class Controller { 
private String radioButtonField = "fachid"; 
private boolean VNGWSelected = false; 

private String select;

public void setSelect(String select){
        this.select = select;   
    if(select.equals("vngw"))
        VNGWSelected = true;
} 

public String getSelect(){
    return select
}

public String search() {... 
    if(!VNGWSelected){
        logger.info("FachID RadioButton selected."); 
    else{... 
        logger.info("VNGW RadioButton selected."); ...} 
    return "personsearch"; 
} ...} ... }
问题回答

暂无回答




相关问题
JSF redirect doesn t work

I have a problem with redirecting a page in my JSF application. My navigation rule look like this : <navigation-rule> <from-view-id>/index.xhtml</from-view-id> <...

Get JSF managed bean by name in any Servlet related class

I m trying to write a custom servlet (for AJAX/JSON) in which I would like to reference my @ManagedBeans by name. I m hoping to map: http://host/app/myBean/myProperty to: @ManagedBean(name="myBean"...

JSF2 - what scope for f:ajax elements?

I have this form: <h:form> <h:outputText value="Tag:" /> <h:inputText value="#{entryRecorder.tag}"> <f:ajax render="category" /> </h:inputText> ...

Modifying JSF Component Tree in PhaseListener

I m having an issue. I ve implemented a PhaseListener, which is meant to add a style class to any UIInput components in the tree that have messages attached to them, and removes the style class if it ...

JSF 2 - clearing component attributes on page load?

The real question: Is there a way to clear certain attributes for all components on an initial page load? Background info: In my application, I have a JSF 2.0 frontend layer that speaks to a service ...

JSF2 - backed by EJB or ManagedBean?

As I am learning JSF2, I realized I am not sure what the backing components should be. From design point of view, what is the difference between EJBs and @ManagedBeans? In the end I am going to use ...

热门标签