When the JSP container processes this page, (i) it invokes the doStartTag() method on the tag handler for the <h:form> action, (ii) writes the "Propety_Label:" template text to the response, (iii) invokes the doStartTag() and the doEndTag() methods on the tag handler for the <h:inputText> action, (iv) and invokes the doEndTag() method on the tag handler for the <h:form> action.
Unless we're careful here, the template text ends up before the <form> and <input> elements generated by the JSF components. To avoid this, the JSF rendering API defines both an encodeBegin() method and an encodeEnd( ) method. For a component that doesn't render its children, like the UIForm component, the tag handler's doStartTag() method calls encodeBegin(), which writes the <form> start tag to the response. The start tag therefore comes before the template text added to the response by the JSP container. The doStartTag() method for the <h:inputText> action then writes the single tag for the <input> element, and the doEndTag() method for the <h:form> action adds the end tag for the <form> element
my question is .... 1) even if there is no encodeBegin() and encodeEnd() methods how can .... the template text ends up before the <form> and <input> elements ??? 2) For a component that doesn't render its children, like the UIForm component, .... what difference will it make if the doStartTag() method writes the <form> instead of the encodeBegin()
Well, to make total sense of what you've posted, I'd probably have to print it out, think about it, and maybe consult a book or two. And I'm too lazy to do that.
But I'd venture a guess that the problem lies in the "Propety_Label: " part of the source. When a JSP tag is defined, it is defined as either having a body or being a standalone tag. Unless I say otherwise, everything that follows is also true of JSF, since it's built on the JSP tag architecture.
A JSP tag makes a decision on when - if ever - to output the generated java code that will then be compiled to form the servlet that renders and transmits the final output data stream (usually HTML text). It can do so when the start tag has been seen and/or when the end tag has been seen. All the body text between the tags gets scooped up and saved until the end tag is detected. The end tag then can use this text in whatever way it wishes. The start tag knows nothing of the body text - it hasn't been scanned yet - but it does know its attribute names and values.
JSF prefers to avoid mixing free text and tagged text. So the "Propety_Label: " string should properly be bracketed with its own tags. Which, if I remember correctly, would be <hutputLabel>Propety_Label: </hutputLabel>. In practical terms, this might mean that the "Propety_Label: " might not render in the right location - if at all.
Because of the nature of the JSF architecture, the tag structure of a JSF page is manipulated as a tree which gets several passes made over it. Straight JSP tags are stream-oriented with a single pass. That also makes a certain difference in how critical it is to use your tags properly.
Customer surveys are for companies who didn't pay proper attention to begin with.
subject: need for encodeBegin() method and an encodeEnd( ) method ??