Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
10. Jun 2008, 13:39 CET | Link

Hi, In my seam app (SEAM 2.0.2.SP1) I´m using a validator to check a value selected in a suggestion box. It works ok, but I want now to pass a parameter to the validator and I don´t manage to do it This is the code:



                 <s:decorate id="entityGroupByBenchmarkDecoration" template="layout/edit.xhtml">
                    <ui:define name="label">#{messages['Benchmark']}</ui:define>
                    <h:inputText id="entityGroupByBenchmarkSi" 
                                 value="#{fundHome.instance.entityGroupByBenchmarkCode.entityGroupCode}"
                                 autocomplete="off"
                                 required="true">
                                                        <a:support event="onblur" ajaxSingle="true">
                                                                <f:setPropertyActionListener value="debeExistir" target="#{benchmarkExistsValidator.tipoVal}" />
                                                        </a:support>                                                                 
                                                <f:validator validatorId="prr.BenchmarkExistsValidator">
                                                <f:param id="abb" binding="#{benchmarkExistsValidator.tipoVal}" value="HOLA" name="validacion"/>
                                                </f:validator>                                
          
                    </h:inputText>
                    <rich:suggestionbox for="entityGroupByBenchmarkSi"
                                        suggestionAction="#{entityGroupSuggest.suggestBenchmark}"
                                        var="entityGroup"
                                        fetchValue="#{entityGroup.entityGroupCode}"
                                        selfRendered="true"
                                        eventsQueue="foo"
                                        ignoreDupResponses="true"
                                        nothingLabel="#{messages['suggestion.no.data']}"
                                        width="200">
                        <h:column>
                            <h:outputText value="#{entityGroup.entityGroupCode}"></h:outputText>
                        </h:column>
                        <h:column>
                            <h:outputText value="#{entityGroup.entityGroupType}"></h:outputText>
                        </h:column>
                        <a:support event="onblur" reRender="entityGroupByBenchmarkDecoration"/>
                    </rich:suggestionbox>
                </s:decorate>                                                     

And this is the validator:


@Name("benchmarkExistsValidator")
public class BenchmarkExistsValidator implements Validator {
    
    private String entityGroupCode;
    private String tipoVal;
    
    @SuppressWarnings("unchecked")
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        System.out.println("benchmarkExistsValidator - value-->"+value.toString()+"<--");
        System.out.println("benchmarkExistsValidator - context.getViewRoot-->"+context.getViewRoot().getViewId() +"<--");
        System.out.println("benchmarkExistsValidator - component.Id-->"+component.getId()+"<--");
        HttpServletRequest myRequest = (HttpServletRequest) context.getExternalContext().getRequest();
        String validacion = myRequest.getParameter("validacion");
        //ALWAYS NULL
System.out.println("validacion-->"+validacion+"<--");
      //ALWAYS NULL
        System.out.println("tipoVal-->"+tipoVal+"<--");

// VALIDATION PROCCESSING...
        }
    }

    public String getEntityGroupCode() {
        return entityGroupCode;
    }

    public void setEntityGroupCode(String entityGroupCode) {
        this.entityGroupCode = entityGroupCode;
    }

        public String getTipoVal() {
                return tipoVal;
        }

        public void setTipoVal(String tipoVal) {
                this.tipoVal = tipoVal;
        }

The problem is that my validate method receives null and setPropertyActionListener doesn´t work in this case, and f:param doesn´t work either. could anyone tell me what am I doing wrong? thanks in advance!

 

Please, rate if you find the answer useful.