Is it possible to use a JSF Validator to perform a Dependency validation?

I'm new to JSF, but getting more and more experience everyday. I've create some custom validators for a few input fields on my form and they are working beautifully. What I can't figure out is how to write a validator that will check a field for a value based on another fields value. For instance, I would like to require a person to enter an address if they select a Yes / No select box indicating they would like to supply an address.
Does anyone know how I can do this? I've come up with a clunky work around by performing my dependency validations in my action page rather than a validator.
Thanks!!!!

Hi RaymondDeCampo.
I have never been a big fan of how JSF (and even Struts)handle forms both in the front (the view) and the back.
Forcing the developer to contend with writing a java class for each thinkable form does not look like a workable pattern to me. And tying the view (JSP or JSF page) tightly to the form classes and validators is also cumbersome.
In many decent applications, the number of forms grows to more than a tiny handful and so would the number of classes that simply act as dummy data carriers.
I do not see why I should have to maintain all the accompanying classes and validators and JSP code that each form comes with. Making changes to the structure of a form (say adding new fields or removing others, or even adding whole form pages into the sequence), modifying the model of a form (like renaming fields, adding new validation rules), or changing form view (e.g. switching from a list of checkboxes to a select dropdown, changing how and where error messages are presented, supporting a new language) are just some of those things that become tedious to maintain sentrally.
No other model of building forms out there makes the named tasks any simpler, aprt from adding a new level of complexity to the simple data collection purpose of web forms. Well, except Formular. I have had Formular working in JSF and Struts although I ended up ditching the JSF way of handling forms altogether.
I prefer good and solid separation of form components as outlined by Formular. Formular is the only API out that would allow me to migrate my forms from any Java web server to another without having to rewrite a line of code. Try upgrading your Struts form to JSF or vise versa and you'll get the idea of why I dropped the more hardwired way of coding web forms.
With Formular, I have created a repository of validators (for doing my form checks). datasources (for populating lists, radios, checkboxes, and combos), and styles (for laying out my form elements). Making modifications to my repositories, I can do site-wide changes without touching my JSPs or Java classes. I can move form messages from the top of ALL my forms and place them just above the offending fields in one single style file, I can swap the markers on optional fields and use them only on required fields if the business manager wants to in a single go, I can even change validation rules that are attached to several fields in different web forms at one instance (how many hours did we save when one client wanted all buttons in the site changed to GIFs and all phone and address fields in their application and survey forms validated a little different?)
Ack! Now It looks like I'm preaching, again so I'll hold myself.

Similar Messages

  • Is it possible to use JSF file as as error page.

    I am using jsf file as an error page.It is working in fine in websphere. But if i am using that only the exception is raised it is not going to error page.
    In Web.XML file,
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <error-page>
    <error-code>403</error-code>          <location>/faces/unauthorized.jsp</location>
    </error-page>
    jsf codings are placed under *.jsp files. In the time submitting form data to server a method throws NumberFormatException. This exception information is displayed in console. but blankpage is coming . It is not redirected to error.jsp fle which is under faces/error.jsp.
    If i am directly giving /error.jsp then it is giving Faces context is not created error.
    So i tried use simple jsp(pure jsp) file wihtin the folder and i set path like /pages/foo.jsp. It is working.
    Tell me is it possible to use jsf as error page.

    What would you hope to do with the reference?  The Mathscript node doesn't have a file reading capability.  You need to read the file and pass the data into the Mathscript node.
    EDIT: I stand corrected.  You need to use the fopen and fclose functions inside of the MathScript node to be able to read a file inside of it.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Is it possible to use two diff forms in same jsp/jsf page?

    Hi all,
    My requirement is to submit the form based on selection of radio button.
    since half part needs to be jsp based which is not using any tags etc.
    But i am trying to use some jsf based component which requires to be inside <f:view><h:form> of
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
    i.e. some <c:comboBox>
    </h:form> </f:view>
    Now earlier i was submitting the form as
    <form action="/techstacks-v2_1/reportAction.do" method="post" name=doSearch id='doSearch'>
    But now i found, in order to use combo box component which is entirely jsf based i need to use <f:view><h:form> which is kind of taking over the previous form submission mechiansm.
    I am trying to keep them separate as two differnt forms.
    one entirely jsp based and other as jsf based.
    Now my question is can i use such way of doing so or is there any better way of implementing so.
    My friend suggested that i can pass the value of jsf based form in hidden form to a input box of form to be submitted finally instead of submitteing two diff forms.
    but in that case also i ahev to use two forms in a single jsp/jsf page.
    suggest me something which can really work out.
    thanks
    vijendra

    You can use as many forms as you want as long as you don't nest forms. The HTML spec probibits that.

  • Is it possible to use my ipad 4 as a second monitor through a USB connection.

    Is it possible to use my ipad 4 as a second monitor through a USB connection.

    perhaps, but my information was current. I had the same question and was looking for and answer and found it. So I responded in order to help others who found this question and were looking for an answer. This community is made more helpful and kept current by adding new answers with current information.
    imobl... air display was a valid response for 2011 predating the question. Also using Monitor2go was valid in 2012. There were USB mirroring and as a 2nd display for an iPad options at the time the original question was asked.

  • Is it possible to use Acrobat 9 sdk to check accessibility?

    Is it possible to use Acrobat 9 sdk to check accessibility of a pdf and get whether the pdf is accessible or not?
    I've found InvokeAccessibilityCheckerCmdSnip.cpp that seems to call accessibility validator, but I don't know if that will make what I need.
    I've been asked to include an accessibility validation utility in a Content Server after loading a pdf.
    Thanks in advance.

    Post your question in the 'Acrobat Developers SDK' forum.

  • Is it possible to use page-scope beans in value expression ?

    Is it possible to use page-scope beans in value expressions ?
    For example,
    <c:forEach items="${DataScreens.records}" var="record" status="status">
    <tr>
      <td><h:command_link action="#{DataScreen.editRecord}">
                    <h:output_text value="#{DataScreen.modifyLabel}" />
                   <!----- PLEASE NOTE THAT status IS OF PAGE-SCOPE IN THE NEXT LINE -->
                   <f:parameter name="id" value="#{status.count}" />
              </h:command>
      </td>
      <td>...</td>
      <td>...</td>
    </tr>
    </c:forEach>In my case, I want to use JSTL instead of <h:dataTable>, because of some special
    requirements in this screen. Can someone please provide me with a workaround ?
    I get the following error on execution..
    12/26/03 16:36:23:734 JST] 59f0302f FacesArraySuf W com.sun.faces.el.ext.FacesA
    rraySuffix Attempt to apply the "." operator to a null value
    [12/26/03 16:36:23:736 JST] 59f0302f FacesArraySuf W com.sun.faces.el.ext.FacesA
    rraySuffix Attempt to apply the "." operator to a null value
    [12/26/03 16:36:23:756 JST] 59f0302f WebGroup E SRVE0026E: [Servlet Error]-
    [Argument Error: One or more parameters are null.]: javax.servlet.jsp.JspExcepti
    on: Argument Error: One or more parameters are null.
    at com.sun.faces.taglib.BaseComponentTag.doEndTag(BaseComponentTag.java:
    961)
    at com.sun.faces.taglib.html_basic.Command_LinkTag.doEndTag(Command_Link
    Tag.java:222)
    at org.apache.jsp._meisaiJoho._jspService(_meisaiJoho.java:365)
    at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.j
    ava:89)
    Thanks,
    Ajay

    Hello Ajay,
    I cant really understand how a particular style can be applied to only an individual column.In the simplest case the attribut 'columnClasses' of data_table contains
    the same number of style classes as you have columns in your table. These
    classes are then applied one to one to the columns.
    If there are fewer classes than columns then you can think of the classes
    beeing repeated until there is one class for each column. In the extreme
    case of only one class this means that this class is applied to all columns.
    The following example shows the simplest case of three columns
    and three classes. Just remove one or two classes from the columnClasses
    attribute to see the 'repeating' behavior.
    Wolfgang Oellinger
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
    <% session.setAttribute("PersonList", new foo.PersonList()); %>
    <f:view>
    <html>
    <head>
        <title>Styled Data Table</title>
        <style>
         /* for the columns */
            .nameClass { width: 30em; color: red; }
            .birthdayClass { width: 12em; color: green; background-color: #ccc; }
            .heightClass { width: 5em; color: blue; }
         /* for the header */
            .yellowClass { background-color: yellow; }
        </style>
    </head>
    <body>
      <h:form>
      <h3>Styled Data Table</h3>
      <h:data_table columnClasses="nameClass,
                                   birthdayClass,
                                   heightClass"
                            style="border: 1px solid black;"
                      headerClass="yellowClass"
                            value="#{PersonList.members}"
                              var="person">
        <h:column>
          <f:facet name="header"><h:output_text value="Name"/></f:facet>
          <h:output_text value="#{person.name}"/>
        </h:column>
        <h:column>
          <f:facet name="header"><h:output_text  value="Birthday"/></f:facet>
          <h:output_text value="#{person.birthday}"/>
        </h:column>
        <h:column>
          <f:facet name="header"><h:output_text  value="Height"/></f:facet>
          <h:output_text value="#{person.height}"/>
        </h:column>
      </h:data_table>
      </h:form>
    </body>
    </html>
    </f:view>

  • Is it possible to use a WVC80N on Virgin Mobiles Mifi2000 Hotspot?

    Anyone know if it is possible to use a WVC80N on Virgin Mobiles Mifi2000 Hotspot?  I live out in the country and the only network connection we have is via the Mifi2000 3G portable Wifi Hotspot.
    So far I have not had any luck setting this up, mainly due to the fact that I can have one device talk to another device locally across the hotspot, so all setup would have to be done on a dummy / closed network.  I tried this but wasn't successful in getting it to accept the Mifi2000 wireless access point.  It saw it and recongnized that it had WPA but after entering the key and complelying what i thought was the last step of the wireless config, it just fails to connect. 
    Of course, the mifi2000 also automatically passes out dynamic ips, so i have to use a DDNS service...but can't get that far.
    Anyone know?
    -Cox

    How many computers do you have in the network?
    What is the IP address and default gateway number on your computer?
    In order to connect to the wireless network, WVC80N should get valid IP address from the access point.
    If the access point has capacity to assign a private IP address to the computers and devices then I think you can use WVC80N.

  • Configuring velocity to use into JSF pages

    Hello to all,
    I am newer with JSF and, I don't know how to insert Velocity code into JSF page. Is it possible? How I must configure my webapp to use Velocity+JSF?
    This is an example of a JSF page that I would be using:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
         pageEncoding="ISO-8859-1"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="/WEB-INF/tld/veltag.tld" prefix="vel"%>
    <html>
    <f:view>
         <head>
         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
         <title>Login</title>
         <f:loadBundle basename="com.tutorial.messages" var="msg" />
         </head>
         <body>     
         #set( $imperial = ["Munetaka","Koreyasu","Hisakira","Morikune"] )  
            #foreach( $shogun in $imperial )
                   $shogun
            #end
         <h:form>
              <h:outputLabel rendered="true" value="#{msg.name}"></h:outputLabel>
         </h:form>
         </body>
    </f:view>
    </html>I'm sorry by my poor English
    Thanks and best regards,
    Shaggy

    Hi,
    I am also trying to develop a similar application but I dont know how to do. Can you please help me regarding that?
    I need to get user's smartcard based certificate to store in server.

  • Possible to aggregate multiple JSF custom actions into a single action?

    I'm wondering if it's possible to aggregate multiple JSF custom actions into a single action? For example, I have a JSF custom tag/renderer named selectOneMenuStateAbbreviation that displays a drop down list of state abbreviations. This tag allows a user to select a state abbrevation from the list.
    What I want to do is create another custom tag/renderer and call it inputAddress. The inputAddress tag, will consist of text boxes for street address, city, and zip code. I want to make it so that the state abbreviation custom tag that I already wrote is imbedded in this tag/renderer as well.
    Does anyone know if this is possible? Or, would I have to just duplicate the code that I already have in my other custom action?

    I would assume so, but, I don't know how. Can I do it using just tags and renderers, or, would I need to create a custom UI component as well? One tag would have to be a child of the other correct? I don't know how to do this in Java code. Does anyone know of example code that shows how to do this?
    Jon

  • Is this possible to do in JSF??

    Hi Crew,
    As per my requirement, I need to develop a framework which takes a fixed format of meta-data and generate the UI as per that meta-data on the fly (Taking care of navigation, method bindings.......and every little stuff). The server will only have the bean objects and there may/may not be entries in the faces-config. Moreover, there will be no JSP's deployed on the server.
    My questions is as follows:
    1) Is it possible to do it using the JSF Framework ? If yes, then how can I do it.......Sample codes/Documents
    Any help is highly appreciated.
    Accid
    Edited by: Accid on Sep 28, 2008 10:06 PM

    Of course it is possible. You will need custom implementations of ViewHandler and NavigationHandler.

  • Using a bean method to perform validation via the validator attribute

    The J2EE tutorial demonstrates a method to perform validation by adding a FacesMessage directly into the FacesContext ... INSTEAD OF throwing a ValidatorException within the method:
    http://docs.oracle.com/javaee/6/tutorial/doc/bnavb.html#bnave
    http://docs.oracle.com/javaee/6/tutorial/doc/bnatn.html#bnatr
    What is NOT mentioned in the tutorials is that, if you simply add a FacesMessage into the FacesContext, the JSF lifecycle UPDATE_MODEL and INVOKE_APPLICATION are still executed even if the validation fails, which is probably not what one intends to happen if the validation fails.
    Instead of simply adding a FacesMessage into the FacesContext, the method performing the validation should instead throw a ValidatorException(FacesMessage) or ValidatorException(Collection<FacesMessage>), so that the UPDATE_MODEL and INVOKE_APPLICATION are NOT executed and you go directly to RENDER_RESPONSE if the validation fails.
    Does anyone see any reason why the tutorial would add the FacesMessage into the FacesContext instead of throwing a ValidatorException ?

    gimbal2 wrote:
    The whole intention of that section seems to be to give an alternative to using a validator. Its the type of validation I tend to use to be honest since I find it the least cumbersome. I agree with you on this one.
    gimbal2 wrote:
    I've hardly ever had any trouble with the extra phases happening... but .. isn't the whole point of PROCESS_VALIDATION lifecycle is to prevent updates to the model when the validation fails ... to skip straight to RENDER_RESPONSE ? I just don't see the point of having the validation failing ( by showing an error to the user ), and yet allowing the "illegal" value updated on the model / bean.
    On a different matter ... I am still not sure how the JSR-303 validation fits in to the JSF lifecycle with regards to updating the model / bean. If you were using JSR-303 validations WITHOUT JSF, like so:
    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory.getValidator();
    Set<ConstraintViolation<Bean>> constraintViolations = validator.validate(bean);.. the bean would have been updated already with the "illegal" values for the JSR-303 validation to work / "detect" that validation fails. Now going back to JSR-303 with JSF, that would suggest that model gets updated before the validation takes place ( to mimic the non-JSF validation above ) ... but that can't be the case as nowhere in the JSF / J2EE documentation ( unless I missed it ) that says that UPDATE_MODEL takes place before PROCESS_VALIDATION only if JSR-303 is used. The JSF lifecycle diagrams always say PROCESS_VALIDATION takes place before UPDATE_MODEL, and only if validation succeeds.
    On the other hand, JBoss' <rich:graphValidator> is clearly documented so that it actually clones the bean and then updates the properties on the clone of the bean, not the bean itself. Hence, the bean must implement the Cloneable interface. ( http://docs.jboss.org/richfaces/4.2.X/4.2.2.Final/Component_Reference/en-US/html/chap-Component_Reference-Validation.html#sect-Component_Reference-Validation-richgraphValidator ). Okay, that link is saying that the use case for <rich:graphValidator> is for cross-field validation, but at least it documents that the model is not updated.

  • Problem with using newer jsf implementation

    Is it possible to use jsf-libraries from wls 10.3.1 on 10.3.0?
    Or how to use newer version of jsf implementation than JSF RI 1.2_03 on wls 10.3?
    I have also use RichFaces 3.3.1 and when I have tried to use Mojarra 1.2_12 richfaces components haven't worked correctly.
    Thanks in advance,
    Luke

    I looked there and
    "If your try to ship your webapplication with a separate JSF implementation, you are free to do this. Keep in mind, that the dependency injection mechanisms does not work with managed beans, if you do not use any of the WLS provided JSF containers.
    Declaring something like this:
    @EJB
    private MySession session;
    will lead to a java.lang.NullPointerException because of the missing depencency injection mechanisms. Would love to know any details about this. Maybe I'll find out more in the future.."
    The problem is that I use annotations like @EJB, so ...
    I'm still waiting for solution how to implement WeblogicInjectionProvider.
    Regards,
    Luke

  • HT3702 Isn't it possible to use my debit card information in payment method information?

    Isn't it possible to use my debit card information in payment method information?

    As far as I know debit cards are no longer accepted as a valid payment method - they are not listed on this page and there have been a number of posts about them being declined. Do you have any of the other payment methods that are shown for your country ?

  • Is it possible to use wildcards to match cell contents in an if statement?

    I need to return a ID along with some other information on a page by page basis, so that the information comes out linked by position.  I use a couple of loops and if statements to navigate through the document.  I am able to use exact matches of cell contents which is fine when the contents doesn't vary.  But the IDs, though they have a similar pattern, are all different. In a menu driven search, I am able to find what I need with '150^9^9^9^9^9-^9^9^9' But when I try putting this (or any number of [0-9], *, ? combinations) it fails.  Is it possible to use wildcards?  The symbol used for the match (==) makes me suspect that it is not possible and that only literal, exact matches will work.  But I wanted to check with the experts before giving up.
    Thanks
    pcbaz

    Thanks for the input.  You're right, a GREP search is much more efficient.  But what I'm trying to do and the circumstances here don't allow me, I think,  to go that route. I am trying to generate a list of values coming from several textframes on a single page and have them come out so that I can tell which values belong together.
    I'm using an inherited document with masters that were created 'manually';  the index numbering for textframes and tables is random. I navigate through the pages, looping through textframe indices asking ' does this textframe exist?' If so, I ask if it is a table -- if no, it is a simple textframe and I ask about the ID, if yes, I ask if the contents of cell (0,0) (invariant position and contents) are equal to the table I want..  I am sending the ID and other pieces of information from the table to one row of a new table on a new page.  So the ID and other information from a single page are linked by being in the same row.
    I know this a little 'off-normal' -- I'm using the search to navigate through the document and find things by location the way you do with a spreadsheet.  I have devised a work-around that helps me get around the fact that the ID is not invariant.  I create a list of the (exact) IDs from another document, equating them to a variable ('a').  I then loop through the list of IDs and ask if the contents of the textframe is equal to 'a'..This works o.k, unless there happens to be an extra space, a different kind of hyphen, etc. It would be so much easier if I could use the wildcards that work in a menu-driven text or GREP search in script just to ask about the contents of the textframe.
    Thanks again
    pcbaz (Peter BIerly)
    P.S. we have since rewritten the masters so this problem will not exist in the future -- we now know exactly which textframe and/or table indices to refer to to get any particular bits of information and don't need to ask questions about the contents.

  • Is it possible to use a cable with two headphone jacks on either end and an electric guitar adapter to record in Garageband?

    Hey everyone,
    I got my Macbook Air (Mid 2013 model) last month and I want to record my acoustic-electric guitar on Garageband (which came with the Air). 
    I don't want to buy a guitar that has a USB. I have a cable with a 3.5 mm headphone jack on both ends like the one pictured here on this website http://www.bestdealaz.com/item.php?id=628 (i didn't buy it from this site though).
    I connected a 6.3 mm guitar adapter (http://www.ebay.com/bhp/headphone-guitar-adapter) to this cable. Then I connected one end of the cable to my guitar and the other end to the Headphone/Microphone jack on the left side of the MBA.
    I saw how other people were saying to go to System Preferences / Sound and then change audio output to audio input.
    I can't do that. I tried.
    Please help!
    Thank you.

    Hello Massimo Pascucci,
    The issue that you are facing when creating an endpoint with internal loadbalancer is the limitation of not allowing same ports to be listening under a single cloud service. This reason for this is that there is a limitation of only one private IP (Also
    known as the Internal load balanced IP) per cloud service.
    There is also a limitation on the Internal load balancer more than one port to be published per load balancer:
    You can leave your feedback by following the link below:
    https://social.msdn.microsoft.com/Forums/en-US/1805c5a0-3906-4cd6-8561-9802d77e0ae5/is-it-possible-to-use-both-an-ilb-and-an-elb-listening-on-the-same-port-in-the-same-azure-cloud?forum=WAVirtualMachinesVirtualNetwork
    Refer to this article for more information on Internal load balancer:
    http://azure.microsoft.com/blog/2014/05/20/internal-load-balancing/
    Thanks,
    Syed Irfan Hussain

Maybe you are looking for