facebook

What’s wrong with validation??? [Closed]

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #212883 Reply

    Idefix
    Member

    Hi,

    I just installed 3.8.0 GA on XP/Eclipse 3 and the first thing that popped into my eyes is Validation is real bad …

    Hibernate mapping XML: A property with the attribute unsaved-value=”null” causes a validation error, saying this attribute must be declared ?!?

    HTML: <table><tr> <td></td> </tr></table> Validation will state the <tr> tag is at an invalid position …

    JSP: All beans defined by Struts tags are not recognized by Validation, exception and error beans are not recognized even so <%@ page isErrorPage=’true’ %> is there … (and the JSP compiles fine)

    JSP: <c:if test='<%=exception == null%>’> delivers the following strange validation error: According to TLD or attribute directive in tag file, attribute test does not accept any expressions.

    As this are really basic things, I can only wonder …

    Thanks,
    Chris

    #212887 Reply

    Riyad Kalla
    Member

    Chris,

    Hibernate mapping XML: A property with the attribute unsaved-value=”null” causes a validation error, saying this attribute must be declared ?!?

    Can you post the file in question so we can check it out?

    HTML: <table><tr> <td></td> </tr></table> Validation will state the <tr> tag is at an invalid position …

    Actually the HTML spec requires TR’s to be inside of <tbody> tags, but we know no one uses them so we need to work on relaxing that. But since it IS spec, just turn off validation and manually use it on HTML files that you need it for.

    JSP: All beans defined by Struts tags are not recognized by Validation, exception and error beans are not recognized even so <%@ page isErrorPage=’true’ %> is there … (and the JSP compiles fine)

    We have a bugfix release comming out soon, can you give a snippet showing the problem and we can try it locally to make sure its fixed?

    JSP: <c:if test='<%=exception == null%>’> delivers the following strange validation error: According to TLD or attribute directive in tag file, attribute test does not accept any expressions.

    This is aknown bug that should be fixed soon.

    Thank you for your help in running these down!

    #212928 Reply

    Idefix
    Member

    Here comes the Hibernate mapping snippet:

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <!DOCTYPE hibernate-mapping PUBLIC “-//Hibernate/Hibernate Mapping DTD 2.0//EN” “http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd”&gt;
    <hibernate-mapping>
    <class name=”com.what.ever.dao.Test” table=”test” schema=”public”>
    <id name=”id” column=”`ID`” type=”java.lang.Long”>
    <generator class=”sequence”>
    <param name=”sequence”>public.”test_ID_seq”</param>
    </generator>
    </id>
    <property name=”personid” column=”`PersonID`” type=”java.lang.Long” length=”8″ not-null=”true” unsaved-value=”null” />
    <property name=”status” column=”`Status`” type=”java.lang.Short” length=”2″ not-null=”true” />
    <property name=”type” column=”`Type`” type=”java.lang.String” not-null=”true” />
    </class>
    </hibernate-mapping>

    As of the <tr> stuff, point taken, but as you say yourself, nobody does so … (Ok, I will from now on … just to be a good boy 😉

    Here comes the JSP error page snippet:

    <%@ page contentType=”text/html”%>
    <%@ page isErrorPage=”true” %>
    <%@ page language=”java” %>

    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-bean&#8221; prefix=”bean” %>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-html&#8221; prefix=”html” %>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-logic&#8221; prefix=”logic” %>
    <%@ taglib uri=”/WEB-INF/c.tld” prefix=”c” %>

    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
    <html:html locale=”true”>
    <head>
    <html:base />

    <title>Exception Error Page</title>

    <meta http-equiv=”pragma” content=”no-cache”>
    <meta http-equiv=”cache-control” content=”no-cache”>
    <meta http-equiv=”expires” content=”0″>
    <meta http-equiv=”description” content=”Showing Exception Error Informations”>
    </head>

    <body>
    <c:if test='<%=exception == null%>’>
    <% exception = (Throwable)request.getAttribute(“exception”); %>
    </c:if>
    </body>
    </html:html>

    But it seems it does recognize the exception definition now … I don’t have any idea why, but this short example will validate if the c:if tag is removed … Maybe this was a combination of different issues that resulted in raising the exception bean as undefined.

    Thanks,
    Chris

    #212943 Reply

    Scott Anderson
    Participant

    The validation of your hibernate file is correct. Here’s the dtd entry for property.

    
    <!ELEMENT property (meta*,column*)>
      <!ATTLIST property name CDATA #REQUIRED>
      <!ATTLIST property access CDATA #IMPLIED>
      <!ATTLIST property type CDATA #IMPLIED>
      <!ATTLIST property column CDATA #IMPLIED>
      <!ATTLIST property length CDATA #IMPLIED>
      <!ATTLIST property not-null (true|false) "false">
      <!ATTLIST property unique (true|false) "false">
      <!ATTLIST property update (true|false) "true">   <!-- only supported for properties of a class (not component) -->
      <!ATTLIST property insert (true|false) "true">   <!-- only supported for properties of a class (not component) -->
      <!ATTLIST property formula CDATA #IMPLIED>       <!-- only supported for properties of a class (not component) -->
      <!ATTLIST property index CDATA #IMPLIED>         <!-- include the columns spanned by this property in an index -->
    
    

    Please note that unsaved-value is not a valid attribute.

    On the <TR>, we’ve relaxed that restriction in the grammar for 3.8.1 and it will go away with the update.
    On JSP validation, it was a bug in 3.8.0 that is fixed in 3.8.1.

    3.8.1 will be released by Monday. Thanks for your patience and sorry for the inconvenience.

    #212946 Reply

    Idefix
    Member

    Whoops, my appologies! You’re right! unsaved-value should be placed in the ID section. I think I need some sleep … once more, sorry! Please be patient with a poor, lonely, hungry, sleepy, pitty worthy guy 😉

    But here’s the last thing I noticed about JSP validation in conjunction with error pages (the following will render invalid due to the error bean not being recognized):

    <%@ page contentType=”text/html”%>
    <%@ page isErrorPage=”true” %>
    <%@ page language=”java” %>

    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-bean&#8221; prefix=”bean” %>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-html&#8221; prefix=”html” %>
    <%@ taglib uri=”http://jakarta.apache.org/struts/tags-logic&#8221; prefix=”logic” %>
    <%@ taglib uri=”/WEB-INF/c.tld” prefix=”c” %>

    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
    <html:html locale=”true”>
    <head>
    <html:base />

    <title>Exception Error Page</title>

    <meta http-equiv=”pragma” content=”no-cache”>
    <meta http-equiv=”cache-control” content=”no-cache”>
    <meta http-equiv=”expires” content=”0″>
    <meta http-equiv=”description” content=”Showing Error Informations”>
    </head>

    <body>
    <html:messages id=”error”>
    <li><%=error%></li>
    </html:messages>
    </body>
    </html:html> 😉 😉

    #212947 Reply

    Idefix
    Member

    And one more thing, there seems to also be a problem with beans declared in included files:

    test.jsp has <%@ include file=”/include/menu.jsp” %>
    /include/menu.jsp has <%@ include file=”/include/login.jsp” %>
    /include/login.jsp has <jsp:useBean id=”person” scope=”session” class=”com.test.dao.Person” />

    The following code in test.jsp renders invalid due to person not being recognized: (Yes, I did include the Person class 😉

    <% if( person==null) person = new Person(); %>

    Or is there another path to include jsp fragment files that would validate properly?

    Cheers,
    Chris

    #212949 Reply

    snpe
    Member

    in prevous message line with
    <li><%=error%></li>

    is invalid

    what is error ?

    regards

    #212950 Reply

    Idefix
    Member

    @snpe wrote:

    in prevous message line with
    <li><%=error%></li>

    is invalid

    what is error ?

    regards

    The <html:message id=”error”> tag defines the error bean which holds messages passed with this request. Just think validation 😉

    Cheers,
    Chris

    #212951 Reply

    snpe
    Member

    You have to define bean error or use jstl, for instance

    <li>${error}</li>

    regards

    #212965 Reply

    Idefix
    Member

    @snpe wrote:

    You have to define bean error or use jstl, for instance
    <li>${error}</li>

    Well, this is exactly what <html:message id=’bean’> is for … please see
    http://struts.apache.org/userGuide/struts-html.html#messages for reference.

    Cheers
    Chris

    #212967 Reply

    snpe
    Member

    I try this file without line wit c.tld (I haven’t this tld in WEB-INF)

    JSP is valid,You set validation to off, It will resolved in 3.8.1 (I think)

    regards

    #212995 Reply

    Scott Anderson
    Participant

    Issues mentioned in this thread were resolved in MyEclipse 3.8.1

Viewing 12 posts - 1 through 12 (of 12 total)
Reply To: What’s wrong with validation??? [Closed]

You must be logged in to post in the forum log in