Getting Substring using JSF

I am new to JSF , (using JSF and struts application ) .I was wondering how I could do basic functions like string manupilation using the JSF core tages ...
For Example if I have
<h:outputText value="#{gen.Name}" />
and I would like to get not the name but say the substring(0,5) ..how would I do this with JSF ...
Also could you please direct me to a resource where I can learn more about the Core (helpful) functions using JSF

Perhaps you could use a converter.
package com.test.converter;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
public final class SubstringConverter implements Converter  {
    public SubstringConverter() {
        super();
    public Object getAsObject( FacesContext arg0, UIComponent arg1, String d ) {
        return d;
    public String getAsString( FacesContext arg0, UIComponent arg1, Object arg2) {
        return ((String)arg2).substring(0,5);
The corresponding entry in faces-config.xml
<converter>
    <converter-id>mySubstringConverter</converter-id>
    <converter-class>com.test.converter.SubstringConverterr</converter-class>
</converter>
Now use it!<h:outputText value="#{gen.Name}" converter="mySubstringConverter"/>

Similar Messages

  • Getting a substring using JSTL

    Have string as below.
    <UL><LI>Required</LI></UL>
    Would like to get only the string "Required" with out any UL stuff.
    is it possible to get this using JSTL? if not how to get the substring "Required".
    Thanks.

    > I was trying to use for display only but <html:errors
    property="custName"/> is returning <UL> instead of a
    String.
    Do you happen to have that set up as the "errors.header" and "errors.footer" properties in your application properties file? You might consider removing the HTML markup and using JSTL to provide an unordered list when desired.
    Hope this helps.
    ~

  • How to get the current JSF phase in backing bean?

    How to get the current JSF phase in backing bean?
    Edited by: jimmy6 on Nov 27, 2007 7:27 AM

    I am using phasetracker to trace it also.I want to know whether it is it render response phase. I know FacesContext.getCurrentInstance().getRenderResponse() work for normal jsf component but it will not work for qiupukit datatable. FacesContext.getCurrentInstance().getRenderResponse() will not return true in the following phase. Why?
    [ INFO] 27-11-07 16:20:21 : BEFORE RENDER_RESPONSE(6) (http-80-Processor23)
    I want the 'get' method of datatable being called in response phase to reduce the number of calling because i put the query in 'get' method there. Actually i still straggling with the best practice to code the datatable...

  • Issues in using JSF UI:Tree tag

    Hi,
    I am trying to work with Tree Structure using JSF UI tags. In Studio Creator i just created a JSP page and designed a Tree with two nodes under it. This is what i have in the body of my jsp.
    <ui:body binding="#{Page1.body1}" id="body1" style="-rave-layout: grid">
    <ui:form binding="#{Page1.form1}" id="form1">
    <ui:tree binding="#{Page1.tree1}" id="tree1" style="left: 48px; top: 48px; position: absolute" text="L3">
    <ui:treeNode binding="#{Page1.treeNode1}" expanded="true" id="treeNode1" style="width: 408px" text="Tree Node 1">
    <f:facet name="image">
    <ui:image binding="#{Page1.image1}" icon="TREE_DOCUMENT" id="image1"/>
    </f:facet>
    </ui:treeNode>
    <ui:treeNode binding="#{Page1.treeNode2}" expanded="true" id="treeNode2" text="Tree Node 2">
    <f:facet name="image">
    <ui:image binding="#{Page1.image2}" icon="TREE_DOCUMENT" id="image2"/>
    </f:facet>
    </ui:treeNode>
    </ui:tree>
    </ui:form>
    </ui:body>
    But when i am trying to launch the jsp page from browser i am getting the below exception.
    com.sun.rave.web.ui.appbase.ApplicationException
    Caused by: java.lang.NullPointerException at java.io.File.(File.java:194) at com.sun.rave.web.ui.renderer.template.xml.XMLLayoutDefinitionManager.getLayoutDefinition(XMLLayoutDefinitionManager.java:142) at com.sun.rave.web.ui.component.TemplateComponentBase.getLayoutDefinition(TemplateComponentBase.java:150) at com.sun.rave.web.ui.renderer.template.TemplateRenderer.encodeBegin(TemplateRenderer.java:73) at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:683)
    Any suggestion to solve this issue would be greatly helpful.

    Now with Unified EL - JSTL and JSF tags are supposed to work on one page.
    If you want to use Unified EL you need
    1) A container that is built on Servlet 2.5 / JSP 2.1 , and example of such a container is Tomcat 6.x
    2) Probably need to upgrade to JSTL 1.2 , and JSF 1.2
    3) If you're upgrading the container to Servlet 2.5 then web.xml should conform to Servlet 2.5 version.
    4) Use correct taglib URIs for JSTL 1.2 and JSF 1.2
    Read here: Summary of new features in JSP 2.1
    http://java.sun.com/developer/technicalArticles/J2EE/jsp_21/index.html
    JSP 2.1 Technology and JSF 1.2 Technology
    http://java.sun.com/developer/community/chat/JavaLive/2004/jl1207.html
    http://java.sun.com/products/jsp/index.jsp
    Message was edited by:
    appy77

  • Using jsf with struts

    hi;
    i am trying to understand the proper architecture when using jsf and struts together.
    i think i understand the differences between the technologies . it seems to me that instead of justifying jsf there should be a focus on how the two technologies actually collaborate.
    specifically, i would like to know or see examples of things like replacing the view portion of struts and plugging in the jsf framework instead or how to i replace the struts actions with jsf commands or maybe they are totally different things.
    where can i get information like this?
    thanks.

    At present, i think the best thing to do is to look at the example provided with the struts-faces integration taglib. I don't know any documentation about it.
    http://cvs.apache.org/builds/jakarta-struts/nightly/struts-faces/

  • Using JSF in search engine.

    Hi,
    I am implementing a search engine. I want to use jsf for for the UI part. I have few queries in this regard.
    - Has anybody used jsf for the same?
    - Since the search result may contain any number of result, then it is not good to first load all the results into a List object and then do the pagination.
    Cheers...

    Hi Tom,
    I am currently involved in developing a web front end for our book search engine. We used JSF and though we had some issues initially, we are pretty happy with the results. You can check it out at http://books.infact.com.
    As for pagenation, the fetching of results (including number of results retrived each time, total count of results etc) should be handled by the back end of your search engine, in my opinion. The JSF part should communicate with the backend to get the number of results it needs to display. Hope that helps.

  • Using JSF in jsp segment page..

    Hello
    Is it possible to use JSF components in a JSP segment page(.jspf) ? I couldn't achive that..Let me explain:
    I created a .jspf file and inserted these lines into it:
    <f:view>
        <h:form id="loginform">
            <h:panelGrid columns="2">
                <h:outputLabel value="User:"/><h:inputText id="username_email"/>
                <h:outputLabel value="Password:"/><h:inputText id="password"/>
            </h:panelGrid>
        </h:form>
    </f:view>after that i included this .jspf file to a jsp file. When I run the application,I get this error:
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    javax.servlet.ServletException: Cannot find FacesContext
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:181)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    root cause
    javax.servlet.jsp.JspException: Cannot find FacesContext
         javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:405)
         com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java:105)
         org.apache.jsp.index_jsp._jspx_meth_f_view_0(index_jsp.java:196)
         org.apache.jsp.index_jsp._jspService(index_jsp.java:113)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.

    I have tried both:
    logincontrol.jspf (1)
    <f:subview id="sv">
        <h:form id="loginform">
            <h:panelGrid columns="2">
                <h:outputLabel value="User:"/><h:inputText id="username_email"/>
                <h:outputLabel value="Pass:"/><h:inputText id="password"/>
            </h:panelGrid>
        </h:form>
    </f:subview>
    logincontrol.jspf (2)
    <f:view>
        <h:form id="loginform">
            <h:panelGrid columns="2">
                <h:outputLabel value="User:"/><h:inputText id="username_email"/>
                <h:outputLabel value="Pass:"/><h:inputText id="password"/>
            </h:panelGrid>
        </h:form>
    </f:view>but nothing changes... i added this line, in the .jsp file:
    <%@ include file="WEB-INF/jspf/logincontrol.jspf" %>   by the way, is it good to write a .jspf file for login process and include it to the pages?

  • How we can use jsf tags in included jsp enclosed in subview tags

    Hello everybody,
    I am developing web app by using jsf. I am including a jsp page "header.jsp" into another jsp page "main.jsp". The header.jsp page is enclosed in jsf subview tag on main.jsp page. The header.jsp contains some static html code and some jsf tags like "outputText". When i added tag library url in header.jsp then my app was not even not initiating and i was getting following exception
    ERROR [UIComponentTag] Faces context not found. getResponseWriter will fail. Check if the FacesServlet has been initialized at all in your web.xml.
    16:22:16,890 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
    java.lang.NullPointerException
    at javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:929)
    at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:310)
    ....Now i removed jsf tag library url from included jsp "header.jsp" so now my app is running but only static html data is being displayed but the value in the jsf tag "outputText" is not being printed in the browser
    kindly help me. i would be very thankful....

    Your question has nothing to do with Sun Java System Directory Server.
    Please use the right forum(s).
    Thanks

  • Query SQL database using JSF problem!! Using CachedRowSet

    I'm using JSF and want to query data from SQL by using CachedRowSet like this,
    rowset.setCommand("SELECT * FROM dbo.SomeTable WHERE SomeField='"+ xyz +"'");
    then check if the record does exist by using
    *if(rowset.next()) {/ do something with the retrieved data}*
    but i get SQLException telling that execute() never called.
    Anyone can tell me what i'm missing? or is there any better way to check the existence of a record ?
    Thanks in advance :-)

    Hi grzegorz,
    1. If your sap application server is unix/aix
      (and not a microsoft OS),
    2. then this kind of secondary databse connection,
       to MS SQL (which is microsoft system),
       is at present not possible.
      (BCOS the required system files, for such
       cross - platform connection is not delivery by sap)
    regards,
    amit m.

  • What do I need to run/use JSF ??

    Sorry for a rather dumb question. We have a client/server system we would like to convert into a Web Based app using JSF.. we developed our system on J2SE 1.4
    1. What software/runtime environment do I need ?
    2. What downloads must I grab to start using it ??
    Thanks very much
    Mike

    Hi,
    first you'll need the JSF (latest current release EA3) found under:
    http://java.sun.com/j2ee/javaserverfaces/
    then an application server, e.g. tomcat/catalina supplied with the JWDSP and the J2EE platform found at:
    http://java.sun.com/webservices/downloads/webservicespack.html
    and
    http://java.sun.com/j2ee/download.html
    respectively.
    Having installed the JSF you'll find a JSF Spec and tutorial where everything else (configuration, etc.) is explained.
    If you're experiencing problems with the JWSDP 1.1 try getting hold of JWSDP 1.01.
    Good luck & have fun....

  • How to dynamically include jsp files using jsf el in include tag ?

    Hi,
    I'm trying to get the jsp file name from my backing bean to use it in an include tag but I can't make it work
    When using this piece of code I can get the generated path
             <h:outputText value="/_partial/#{myBean.jspName}.jsp"/>whereas in this code the jsf el is not replaced by this value.
            <%@ include file="/_partial/#{myBean.jspName}.jsp" %> Have you any idea of how to solve this ? I'm currently developing for J2EE 1.4 platform.     
    Thanks for your help,
    Regards.

    If you're using JSF 1.2 and JSTL 1.2 at a JSP 2.1 environment, then you can just use <jsp:include> with unified EL.
    If you're using JSF 1.1, then you may find this article useful [http://balusc.blogspot.com/2007/01/dynamic-jsf-subviews.html]

  • Why JSF & When to use JSF?

    Hi Experts,
    I am new to JSF and i am studying that now. I have some basic questions.
    1. Why JSF and When to use JSF means What is the right requirement or situation to use JSF?
    2. Studied that JSF is basically a UI driven framework and developed to provide & support for UI component model. If that is the case, each UI components(Textfield, drop-down, etc..) in the web page is coupled to server-side components and for each validation or events, is the page submitted to server and come back?
    3. What are the other benefits i get compared to Struts and JSP if i use JSF?
    Please provide your experience.
    Thanks,.
    Edited by: MouliOnTech on Mar 6, 2009 3:02 AM

    Depends on how you code the JSF page and which component library you use.
    Standard JSF components doesn´t support asynchronous requests, so the validation will only happen when you submit the form to the server (either by pressing the submit button or by Javascript´s form.submit). But there are also Ajaxical JSF component libraries out which can validate asynchronously based on the (Javascript) events. For example RichFaces/Ajax4jsf.

  • Shortest path to get started with JSF project

    Hello,
    I am looking for a path of least resistance (or effort) to get started with JSF. This is really an add to the "JSP due diligence" thread that I started but with a specific question. At this time, I am primarily interested in implementing an MVC framework. The components of JSF seem interesting and I think will be valuable to us, but it would be too much to bite off at this time. So, could I implement JSF with my JSP pages (with code to use the backing beans but my own html components) and then later add JSF components as the next step? Perhaps this is non sensical but appreciate you saying that so I know how much effort is involved.
    Thanks!
    Priya

    Trying to use JSF without the JSF components sounds like it would be harder. Much of the benefit of JSF is the binding of bean properties to component values.

  • I can't sign in to iCloud. My Apple ID is valid, but os not an iCloud account. How do I get to use iCloud?

    I can't sign in to iCloud. My Apple ID is valid, but is not valid for iCloud. How do I get to use iCloud?

    You are getting this message because you are trying to create an iCloud account on a PC by signing with your Apple ID.  You can only sign into an existing account on a PC.  You first have to create iCloud account on an iOS device (iPhone, iPad or iPod Touch) running iOS 5 or higher, or on a Mac running OS X Lion (10.7.5) or higher.  After creating your account on one of these devices you will then be able to sign into the account using this ID on your PC.

  • Can't get and use an apple id for cloud or apps or store when i try to change it it will let me but then everytime it keeps asking me to chang e password everytime cant get my computer to just accept one password that will keep

    can't get and use an apple id for cloud or apps or store when i try to change it it will let me but then everytime it keeps asking me to chang e password everytime cant get my computer to just accept one password that will keep

    Just what are you doing and what is the exact wording of the message you are getting?

Maybe you are looking for

  • How can i print a scrit to keep in wait for some time then be printed

    Hi Experts, This is sheela reddy.I am new to SDN. I need your help. as per my requirement there is a trasaction code .let say X. So when i excute X and save the data through the Tcode,then it automtically calls script and given for printing Since the

  • Query Schedule Report

    Hello. I got the error below in the scheduled report. When I create text with no HTML programming the system sends the email without attachments, when I create programming with HTML body it reports me the following error and does not send the email.

  • How to get name of a graphic object

    Hi all, i created various grids and graphic obejcts in a splitter container. Now i want to set focus ( cl_gui_control=>set_focus )on the graphics objects, but i dont know the control names. for the grid this is no problem, but as i created the graphi

  • When i sync my iphone, purchased songs gets back on my phone

    Even though I have deleted the songs on my phone, every single time I sync my phone, the songs reappear. How can I prevent this from happening? So I only fet my assigned playlist synced. I am very annoyed, so I hope someone can help me!

  • Problem Posting a Group of Calendars

    HI, I have 4 people that I keep calendars for. Each person has a different color on my ical so I know what each person is doing. The task does not identify the person on my ical at all, just the color. When I publish the Group, the color for each per