JSF tag/tag attribute reference?

Is there a place where I can references for the various JSF tags and their attributes, fx. the validators and which attributes they support and so on?

The right place to check is the html_basic.tld and jsf_core.tld. These are part of the jsf-ri.jar.

Similar Messages

  • JSP ${} expressions in JSF tag attributes

    Does anyone know why the expert group decided not to allow ${} style expressions within JSF tag attributes? I understand that a different syntax is needed to implement the 'late binding' #{} expressions used to link input controls to form beans, but not why the JSF tags actually prevent the use of immediately evaluated ${} expressions for accessing variables in the page scope in JSP 2.0.
    I know there has been a lot of discussion about this and other threads mention a security loophole that would be opened up by allowing expressions like #{blah.${someProperty}}, but I'm not sure why this sort of thing would cause a problem. Is there any way to enable this behaviour, such as editing the JSF tag library descriptors to allow runtime expressions (horrible though that sounds)? Or perhaps another JSF implementation that supports both immediately evaluated and late-binding expressions? It seems a rather unnecessary restriction that is going to cause much confusion and mistyping for all...
    Thanks in advance,
    Keith.

    Thanks Adam, I see the problem now. It's a fairly obscure loophole but serious nonetheless. Of course, this problem could also be avoided by not using request parameters within JSF tags as it doesn't affect the majority of legitimate uses for expressions.
    I have to disagree with you about mixing ${} and #{} expressions though. The majority of developers will be used to writing ${} expressions in JSTL and JSP text and so will expect them to do work the same in JSF tags. Judging by the number of posts in this forum about being unable to use page scope variables in JSF tags this issue is already confusing a lot of people.
    As a rule of thumb, "use ${} for expressions that are output to the page and #{} for binding controls to backing beans and invoking methods" (which perform clearly distinct functions) is a lot simpler and easier to learn IMHO than the current one, which is "use ${} for expressions that are output to the page except within a JSF tag, where you use #{} for the same thing and also to update form values and invoke action methods"! (OK, I'm exaggerating a little for effect, but you get the point... :-)
    I agree that mixing both types of expression in the same attribute might be a little confusing, but this is an unlikely edge case that should probably be prevented in value binding or action attributes anyway. It's more of an issue for label values where mistyping one for the other is already very common and, although not especially difficult to debug, is just another pitfall awaiting the unwary JSP developer. I'm not sure that JSP expressions would be much more difficult to debug anyway as the value and method bindings will simply not work, which is pretty obvious as soon as you try and test the thing.
    Is this something that the EG would be prepared to reconsider for the next release of JSF, or perhaps getting the security loophole addressed in the next JSP spec? In the meantime, is there any reason that developers shouldn't enable runtime expressions in the TLD file provided that they're willing to live with the consequences?
    (Sorry to harp on about it, but I've already had several complaints about this after recommending JavaServer Faces for a major development project at ingenta.com.)
    Many thanks,
    Keith.

  • How do I use the ? operator in JSF tag attributes?

    I want to do something like this:
    <h:inputText styleClass="${myBean.valid ? 'styleA' : styleB'}" ...>
    What do I have to do to use this Expression language?
    With the #{...} expression the ? operator doesnt seem to be available.
    When I use the ${...} expression I am getting this error:
    javax.servlet.ServletException: ServletException in '/WEB-INF/body/Test.jsp': /WEB-INF/body/Test.jsp(12,5) According to TLD or attribute directive in tag file, attribute styleClass does not accept any expressions
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:121)
    Can anybody please help?
    Thanks!

    Personally, i'd do:
    <h:inputText styleClass="styleA" rendered="#{myBean.valid}"/>
    <h:inputText styleClass="styleB" rendered="#{!myBean.valid}"/>

  • Pass arguments to JSF tag attributes like id oder value

    Hi!
    I started with JSF some weeks ago and have some questions that i could not find in FAQ or tutorials.
    My page structure uses some <jsp:includes>. Each included page uses JSF.
    The structure is (example - users):
    Users.jsp
    |
    |(incl)
    |
    Mainpage.jsp (=Framework)
    |
    |(incl)
    |
    Browser.jsp (=Table)
    In "Users" all specific data is set. In "Browser" there is a <h:form> tag and a <h:dataTable> tag.
    The result should be a simple table with users inside.
    So I want to pass arguments to those sub-pages.
    1) -> form-ids as parameter:
    <h:form id="#{sessionScope.formName}">
    ... does not work, because ids have to start with a character or "_".
    formName is set as followed:
    session.setAttribute("formName", "form_users");
    2) ->beans as parameter:
    <h:dataTable id="browser_table_#{sessionScope.id}" styleClass="browser_table"
    var="user" value="#{sessionScope.user_list}">
    ... does not work. "id" is requested to be a static value and "value" can't find the bean by this string.
    user_list is set as followed:
    session.setAttribute("user_list", "UserListBean.users");
    (UserListBean.users is an ArrayList)
    Is there an error in my thinking? Or is there a way to pass arguments as i want?
    Thanks!

    sorry ... mistake in topic: "oder" = "or" of course :)

  • Using TAG Attributes within JSF Tags

    I'm using some .tag files for templating purposes. I'm using two tag attributes via <@% attribute %> directive. How can i access this attribute to do something like follows.
    <%@ tag display-name="Area de Trabajo" language="java" %>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <%@ taglib prefix="t" uri="http://myfaces.apache.org/tomahawk"%>
    <%@ attribute name="title" required="true"%>
    <%@ attribute name="location" %>
    <t:div styleClass="zonaArea#{(not empty location) ? location : 'Global'}">
      <h:panelGrid columns="1">
        <h:outputText value="#{title}" />
      </h:panelGrid>
      <jsp:doBody />
    </t:div>

    Hola Alberto.
    Any luck? Did you worked that around?
    I'm just trying to do the same thing...
    Tried to do something like:
    <%@attribute name="enabled" type="java.lang.String" %>
    <h:outputText value="test: #{requestScope['enabled']}" style="font-weight: bold;" /> to no avail...
    Let me know, please!
    Hi,
    Manrico

  • Replace JSF tag by an own tag

    Hi,
    I'm trying to replace a <h:inputText> by my own tag. The used HtmlInputText component should not be replaced.
    The reason is, that i want to pass permissions to the tag and map them to readonly and rendered attributes. My Problem is, that my own tag doesn't reolv bean values. If i use the <h:inputText> the bean values show up correctly. If i use my own tag, the input text shows "#{myBean.value}".
    What could be the problem?
    Thx in advance
    Henrik
    Here is my tag:
    import javax.faces.component.UIComponent;
    import javax.faces.component.html.HtmlInputText;
    import javax.faces.context.FacesContext;
    import javax.faces.webapp.UIComponentTag;
    import com.arvato.jsf.security.JSFSecurity;
    import com.arvato.jsf.security.Permissions;
    import com.sun.faces.taglib.html_basic.InputTextTag;
    public class ArvatoTextFieldTag extends InputTextTag {
        private String role;
        private String onkeypress;
        private String id;
        private String value;
        public String getRole() {
            return role;
        public void setRole(String permissions) {
            this.role = permissions;
        protected void setProperties(UIComponent component) {
            super.setProperties(component);
            if(id != null) {
                component.getAttributes().put("id", id);
            if(onkeypress != null) {
                component.getAttributes().put("onkeypress", onkeypress);
            if(value != null) {
                component.getAttributes().put("value", value);
            if(role != null) {
                FacesContext facesContext = FacesContext.getCurrentInstance();
                Permissions p = JSFSecurity.getInstance().getPermissionsForRole(role, facesContext);
                if(!p.isWritable()) {
                    component.getAttributes().put("readonly", true);
                if(!p.isReadable()) {
                    component.getAttributes().put("rendered", false);
            } else {
                component.getAttributes().put("readonly", false);
                component.getAttributes().put("rendered", true);
        @Override
        public String getComponentType() {
            return "javax.faces.HtmlInputText";
        @Override
        public String getRendererType() {
            return null; // no standalone renderer
        @Override
        public void release() {
            super.release();
            role = null;
        public String getValue() {
            return value;
        public void setValue(String value) {
            this.value = value;
        public String getOnkeypress() {
            return onkeypress;
        public void setOnkeypress(String onkeypress) {
            this.onkeypress = onkeypress;
        public String getId() {
            return id;
        public void setId(String id) {
            this.id = id;
    }and my tld definition:
    <taglib>
       <tlib-version>0.03</tlib-version>
       <jsp-version>1.2</jsp-version>
       <short-name>arvato-jsf</short-name>
       <uri>http://arvato.com/jsf/component/tags</uri>
       <description>Arvato JSF tags</description>
       <tag>
          <name>textfield</name>
          <tag-class>com.arvato.jsf.tag.ArvatoTextFieldTag</tag-class>
          <attribute>
             <name>id</name>
          </attribute>
          <attribute>
             <name>role</name>
          </attribute>
          <attribute>
             <name>value</name>
          </attribute>
          <attribute>
             <name>onkeypress</name>
          </attribute>
       </tag>
    </taglib>

    In the setProperties method, you've got to resolve the valuebinding (#{blah.whatever}) to get the actual value. But you only want to do that if the attribute is set to a valuebinding.
    Here's an example:
          * @see javax.faces.webapp.UIComponentTag#setProperties(UIComponent)
         protected void setProperties(UIComponent component) {
              super.setProperties(component);
              //Set the field reference property
              if (fieldRef != null) {
                   if (UIComponentTag.isValueReference(fieldRef)) {
                        ValueBinding vb = getFacesContext().getApplication().
                             createValueBinding(fieldRef);
                        component.setValueBinding("fieldRef", vb);
                   } else {
                        component.getAttributes().put("fieldRef", fieldRef);
         }This example shows how to determine if the "fieldRef" attribute is a value binding, and extracts the value accordingly. But there's one more step. In your component class, or anywhere you access the attributes of your custom tag, use the following code:
         public String getFieldRef() {
              if (fieldRef != null)
                   return fieldRef;
              ValueBinding vb = getValueBinding("fieldRef");
              if (vb != null)
                   return (String)vb.getValue(getFacesContext());
              else
                   return null;
         }The above snippet is what you would put in your custom component getter method.
    JSF is open source. Something I found very helpful while learning how to create custom components was looking at how the JSF developers created theirs. You should go ahead and download the JSF source code.
    CowKing

  • Custom tag attribute calculated by scriptlet expression

    Hi,
              If I set the rtexprvalue subelement of the attribute element in my tld to
              "true", should I be able to dynamically determine the value of my custom tag
              attribute using a scriptlet expression?
              When I include the custom tag reference:
              <prod:getCategory id="category"
              categoryID="<%=request.getParameter("catID")%>" scope="page"/>
              it actually gets written to the html as:
              <prod:getCategory id="category" categoryID="2133" scope="page"/>
              and is not recognized as a jsp tag.
              I am using weblogic 6.0 sp1.
              Thanks in advance!
              daniel
              

    I had the same problem in a design a couple of months ago and could not get around it so I switched the functionality into code and out of the tag lib.
    I take it you are trying to do something like this?
    <%
    String value="hiworld";
    %>
    <mytaglib:saysomething value="<%=value%>"/>

  • Using JSP scriplets in the JSF tags

    Hi,
    I haven't done that much JSP development using various tag libraries prior to looking at JSF, hence this very basic question:
    I am declaring and manipulating Java variables in my JSP. Is there a way to access those in my JSF tags? It seems that something like:
    <%
    String myString="MyLabel";
    %>
    <h:view>
    <h:outputText id="myID" value="<%=myString%>" />
    </h:view>
    blows up in the JSF processor.
    I am porting some stuff to JSF and hence do not use backing beans in all cases.
    Any suggestions/ideas/pointers are greatly appreciated.
    Thanks in advance,
    Vadim.

    JSF action element attributes take JSF EL expressions, not Java expressions. A JSF EL expression has access to objects in one of request, session or application scope only, not to scripting variables. One way to get your example to work is by putting the String in one of these scopes within the scriptlet, e.g.:
    <%
      String myString="MyLabel";
      request.setAttribute("myString", myString);
    %>
    <h:view>
      <h:outputText id="myID" value="#{myString}" />
    </h:view>But, if you're porting a JSP-based application to JSF, I strongly recommend that you move all scriptlet code into beans; otherwise it's kind of pointless to migrate to JSF. The strength of JSF is its separation of UI layout and application logic.
    Even though JSP happens to be one way to wire up a JSF view with JSF components, JSF has very little to do with JSP. You need to understand the basic JSF component model, event-driven development, and use JavaBeans to really gain any benefits. Don't be fooled into believing that JSF is "just a new JSP tag library" by the support for JSP as the default presentation layer; it's far more than that, and I personally believe that using JSP as the presentation layer makes using JSF a lot harder than it should be. In fact, most of the issues posted in this forum are issues with the JSP layer, not with the core JSF components or the infrastructure classes.
    Hans Bergsten (EG member)

  • JSF tag inside another JSF tag

    Hi,
    Note: It's a bit of a long post but I will try to cut to the point without leaving behind any pertinent details.
    I've created some simple custom JSF tags in the past. The tags usually consisted of one or two attributes that would be beans. The tags would then print out the data for those beans or process them and then output the results.
    What I am trying to do now is a bit more complicated for me. I have a JSP page with a scriplet on it. It iterates over a bean containing a list of items. The loop adds those items to an HTML select menu one at a time. The outline of the code looks similar to this,
    <% extract data List from the bean and store it in variable called dataList %>
    <select>
    <%
      for (int i=0; i<dataList.size(); i++;){
        ListItem item = dataList.get(i);
        String name = item.getName();
        String value = item.getValue();
    %>
    <option value="<%=value%>">
      <%=name%>
    </option>
    <%}%>
    </select>
    <h:commandButton id="gobtn" action="go_to_page" actionListener="#{action.fetch}" value="Go"/>What I want to do is take all the above code and put it into a custom JSF tag. This tag would contain all the scriplet code, output the HTML code and also the commandButton code at the end.
    All of that is pretty easy except for the commandButton part. I am not sure how to output a commandButton from a custom JSF tag. How do I pass it the action.fetch part for the actionListener attribute? Can I create a commandButton object in my custom JSF tag and pass it this information?
    I've followed a tutorial at this site in the past but it doesn't go into too much detail
    http://www.exadel.com/tutorial/jsf/jsftutorial-customcomponents.html
    Any help is appreciated,
    Nick

    I guess I missed some information. The dataList in the bean is stored in a HashMap. So some work has to be done with the bean before hand to determine what list to pull out and then "massage" it a bit for viewer consumption. This is not easily accomplished with the standard JSF html tags, hence my going with a custom tag approach.
    Processing this bean and getting a list from the Hashmap in the bean before displaying it is easy, so is outputting the HTML. The hard part is rendering the commandButton with all the attributes I listed previously.
    Is there a way in general to have other JSF tags nested inside a custom JSF tag?

  • Hiding conditional logic using JSF tags

    Hi
    I'm trying to encapsulate some logic which, dependent on a true / false validation, outputs either one component or another containing a value.
    For example...
    when the validation is true, output <h:selectOneMenu... containing all available values with selected value highlighted.
    when the validation is false, output <h:outputText... containing selected value.
    I've tried custom tags but I'm using this to write out very basic tags and I'd prefer to use the JSF HTML tags.
    The only option I can see is to write conditional logic in the JSPs to say:
    if valid = true
    <h:selectOneMenu...
    else
    <h:outputText...
    endif
    ...but this means the developers must do this for every occurrence and the pages contain lots of conditional logic.
    Is there any way to create a custom JSF tag which outputs JSF HTML tags as this seems to be what we want to do?
    Thanks D

    There is no tag for this, but every HTML component has a 'rendered' attribute which accepts a boolean expression. If it's outcome is true, then the component will be rendered, otherwise it will be hidden.
    Here are some basic examples:
    <h:someComponent rendered="#{myBean.booleanValue}" />
    <h:someComponent rendered="#{myBean.intValue > 10}" />
    <h:someComponent rendered="#{myBean.objectValue == null}" />
    <h:someComponent rendered="#{myBean.stringValue != 'someValue'}" />
    <h:someComponent rendered="#{!empty myBean.collectionValue}" />
    <h:someComponent rendered="#{!myBean.booleanValue && myBean.intValue != 0}" />
    <h:someComponent rendered="#{myBean.stringValue == 'oneValue' || myBean.stringValue == 'anotherValue'}" />

  • How to lookup what datatype JSF tag component requires?

    Kinda beginner question following on my part and not sure I'm asking this in the correct web-page speak?
    I just happen to know if I have a tag such as <af:tree>, I know its value attribute requires an instance of oracle.adf.view.faces.model.TreeModel at runtime.
    However how do I determine specifically the datatype that the tag-attribute requires at design time? For the majority of tags in JSF/ADF Faces this will be strings, but for tricky tags like <af:tree> how can I work this out?
    The tag doco doesn't mention this. Do I need to go to the tag libraries? How would I do this in JDeveloper? Does JDeveloper provide any other help on looking this up?
    Any help appreciated.
    Regards,
    CM.

    The tagdoc for tree at
    http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/tagdoc/core/tree.html
    says about the value attribute:
    "the hierarchy of tree data - must be of type oracle.adf.view.faces.model.TreeModel"
    As to how I found that? Google. I find ADF documentation very hard to find any other way and often end up googling things like:
    adf af:tree value site:oracle.com
    Not exactly what you were looking for, I know, but hope it is of some help.

  • Error Accessing JSF Tags in html div

    Hi,
    I am getting an error when trying to access <h:outputTest from within div. I am trying to embed a style sheet dynamically into the div.
    Following is my code:
    <div class="headerSDPLogo <h:outputText value='#{nlsSupport.align_logo}'/> ">The JSF tag isnt parsed at all. Accessing <h:outputText returns me this error.
    com.sun.facelets.FaceletException:
    Error Traced[line: 13] The value of attribute "class" associated with an element type "div" must not contain the '<' character.What could be the possible turnaround to this.
    Thanks.

    Mujju101 wrote:
    <div class="headerSDPLogo <h:outputText value='#{nlsSupport.align_logo}'/> ">What could be the possible turnaround to this.This perhaps?
    <div class="headerSDPLogo #{nlsSupport.align_logo}">

  • JSF Tags value and valueRef

    Hey
    Does anybody know if these two attributes (value and valueRef) mean the same thing in the JSF tag libraries???
    I am the JWSDP tutorial and some of the examples use value but this does not exist as an attribute for that tag for example
    <f:selectitem itemLabel="Pear"
    value="#{currentFruits.pearSelected}" >
    The tag selectitem does not have a value attribute! it has valueRef and itemValue.
    Ta.

    Hi
    in 1.0_final there is only value-attribute
    cheers,

  • Variable Substitution with tag attribute

    Hi,
    is possible to use variable substitution with tag attribute? as follow:
    <root directory="xxx"  filename="yyy">
       <....
    </root>
    using variable substitution for directory : root,1,directory,1
                                                               root,1,filename,1

    Hi,
    I solved my problem using Dynamic Configuration to set the FileName and Directory fields in Adapter Specific Configuration. To use Variable Substitution only accept element in XML.
    Thanks for all.

  • Unable to Deploy WAR file  (Unknown assembly root-tag attribute: version)

    Hello,
    I created a simple web application with eclipse + tomcat plugin + struts2 (JPA Spring Hibernate ) and created the WAR file using the tomcat plugin compiler. When I deploy the war file into Tomcat 6 the file is deployed properly and i can view the website properly. But when I try to deploy the the WAR file from Oracle 9i Application Server I get the following error.
    Failed to deploy web application "mytest". Nested exception Root Cause: Error loading web-app 'mytest' at C:\ora9ias\j2ee\MySystem\applications\mytest\mytest: Unknown assembly root-tag attribute: version; nested exception is: java.lang.InstantiationException: Error loading web-app 'SFPD' at C:\ora9ias\j2ee\MySystem\applications\mytest\mytest: Unknown assembly root-tag attribute: version.
    My Current web.xml is this.
    <?xml version="1.0" ?>
    <web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>My Test Project System</display-name>
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>
    </web-app>
    thanks in advance,

    Thanks for the reply sasesha,
    I've changed my web.xml to
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
         "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>     
         <display-name>My Test Project System</display-name>
         <filter>
              <filter-name>struts2</filter-name>
              <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
         </filter>
         <filter-mapping>
              <filter-name>struts2</filter-name>
              <url-pattern>/*</url-pattern>
         </filter-mapping>
         <listener>
              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
         </listener>
         <welcome-file-list>
              <welcome-file>index.html</welcome-file>
         </welcome-file-list>
    </web-app>
    During the initial upload the previous error doesn't show anymore, however, I'm getting this new error and currently I'm a bit at a loss since i included the spring.jar library file in my war file. I tried the new war file in Tomcat and the war file deploys fine. Am I missing a configuration or setup ?
    Failed to deploy web application "mytest". Nested exception Root Cause: Class not found: org.springframework.beans.factory.BeanDefinitionStoreException; nested exception is: java.lang.ClassNotFoundException: org.springframework.beans.factory.BeanDefinitionStoreException. Class not found: org.springframework.beans.factory.BeanDefinitionStoreException; nested exception is: java.lang.ClassNotFoundException: org.springframework.beans.factory.BeanDefinitionStoreException
    Thanks again,
    sethsera

Maybe you are looking for

  • Problem with model compilation

    Is it possible to create and compile model based on concat dimension? I try to do so model creates but when I try to compile such model, server closes connection. I use 10.2 Oracle

  • Delta Skymiles AMEX Gold Approved with Bankruptcy!!

    Just got an instant approval online!!  Credit line is $2,000.  I have applied about 4 times for this card over the past few years, declined each time.  They checked Experian my Fico score is 664 and I have 30+ inquires (i'm a credit junkie too...I ha

  • Fixed order of photos for album w/o sorting

    When importing photos, PSE (by default) imports using a LIFO (Last In First Out) method - hence photos are in choronological order from last to first taken. If photos are from, say, a vacation, this is a problem since nobody wants to see their vacati

  • Commit per session

    hi guru's i have one little question which v$view can tell us " how many commits done by user x in particular session" ???? thanks for response

  • Alerts and Reporting

    I am using ALSB 2.6 Question 1. There is an option in the Alert Destination to send the message to?Reporting? (a selection of yes or no) This is documented to be: ?Reporting: If you specify Reporting, alerts are sent to the ALSB Reporting module and