Frage

I made following jsf page. In my Managed Bean i want evaluate the input, but i dont get the values.

If i press my commandLink i dont get any values. when i use a commandButton it works:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="../templates/common.xhtml">
    <ui:define name="pageTitle">Test</ui:define>
    <ui:define name="pageHeader">Test</ui:define>
    <ui:define name="body">
        <h:panelGroup id="messagePanel" layout="block">
            <h:messages errorStyle="color: red" infoStyle="color: green"
                layout="table" />
        </h:panelGroup>
        <h:form>
            <h:outputLabel value="#{bundle.SearchAdressLabel_name}"
                for="axname" />
             <h:inputText id="axname"
                    value="#tbaxController.name}"
                    title="#{bundle.SearchAdressTitle_name}" />
                     </h:panelGrid>
            <br />
            <br />
            <h:commandButton id="submit" value="#{bundle.SearchAdressLabel_cmdsearch}"  action="#{tbaxController.prepareList}">
        </h:commandButton>

            <h:commandLink action="#{tbaxController.prepareList}"
                value="#{bundle.SearchAdressLabel_cmdsearch}" immediate="true" />  
            <br />
            <br />
            <h:commandLink value="#{bundle.SearchAdressLabel_cmdclear}"
                type="reset" />
        </h:form>
    </ui:define>
</ui:composition>
</html>

Here is a part of my MB:

@ManagedBean(name = "tbaxController")
@SessionScoped
public class tbaxController implements Serializable {

    private static final long serialVersionUID = 1L;
    private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
            .getLogger(tbaxController.class);

    private Tbax current;
    private DataModel items = null;
    @EJB
    private TbaxFacade ejbFacade;
    private PaginationHelper pagination;
    private int selectedItemIndex;

    private String name;


    public tbaxController() {
    }

    public String getname() {
        // Get the field
        return searchAxart;
    }

    public void setname(String oname) {
        // Set the field this.searchAxart
        this.name = oname.trim();
    }

    ...

    public String prepareList() {
        logger.info("prepareList:" + name); **//null with commandLink!
        recreateModel();
        return "ADList";
    }

     ...

Why does my prepareList method doesn't get any values with a commandLink?

War es hilfreich?

Lösung

The immediate="true" makes jsf to step over the process validation and update model phases. It jump directly to invoke application phase. That's why you don't get any values on the model. Try removing it and see what happens.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top