Parametrized JSF Converter

Hello
my question:
for example i have a h:selectOneMenu, witch present the streets in the any (chose before) town
this selection in xhtml page looks like
<h:selectOneMenu id="town_4"     value="#{locationAddAction.street}" immediate="true">
     <f:selectItems value="#{locationAddAction.streetLookup}" />
     <fmedia:streetConverter town="#{locationAddAction.town}" />
</h:selectOneMenu>in my project i need to convert a string into Street object stored in DB
but there are can be many streets with the same names, but difference in town reference
so i need the town attribute in converter
my converter class extends javax.faces.convert.Converter
public class StreetConverter implements Converter {
     private LocationService locationService = new LocationService();
     private Town town;
     @Override
     public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
          Town town = locationService.getStreetByNameMatch(town,arg2)
          return town;
     @Override
     public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
          if (arg2 instanceof Street)
               return ((Street) arg2).getName();
          return null;
     public Town getTown() {
          return town;
     public void setTown(Town town) {
                this.town = town;
}i registered my converter with parameter in faces-config.xml
<converter>
          <converter-id>streetConverter</converter-id>
          <converter-class>package.StreetConverter</converter-class>
          <attribute>
               <attribute-name>town</attribute-name>
               <attribute-class>package.Town</attribute-class>
          </attribute>
     </converter>and create my facelet tag
<tag>
          <tag-name>streetConverter</tag-name>
          <converter>
               <converter-id>streetConverter</converter-id>
          </converter>
     </tag>PROBLEM:
any request to my converter (StreetConverter, <fmedia:streetConverter>) set the new creation of my Converter
but the initialization of "town" field happend only once in creation page (when i'm requesting whole jsf page) and any request to converter is erasing my town parameter, becouse it has been init in another converter object.
how can i initialize town attribute in all requests to converter ?
sorry my horrible english
thanks =)

Use f:attribute:<h:someComponent>
    <f:converter converterId="streetConverter" />
    <f:attribute name="town" value="#{bean.town}" />
</h:someComponent>
public X getAsX(FacesContext context, UIComponent component, Y value) {
    Object town = component.getAttributes().get("town");
}Alternatively just get the bean from context:
public X getAsX(FacesContext context, UIComponent component, Y value) {
    Bean bean = (Bean) context.getApplication().evaluateExpressionGet(context, "#{bean}", Bean.class);
    Town town = bean.getTown();
}

Similar Messages

  • Injecting EJB to JSF Converter

    Is it possible to inject EJB (or at least EntityManager) to JSF Converter or Validator?
    I don't know if i'm missing something or is it just impossible - it works when injecting EJB into Managed Bean.
    Thanks.
    S&#322;awek S.

    Slawek_Sobotka wrote:
    Thanks.
    So I'll redefine my question to be problem oriented:
    I have SelectItem that contains Address object.
    I have implemented AddressConverter so that it converts Adress to String simply by using it's id.
    How to convert back: from string (address's id) do Address object?Map it. Two general ways are mentioned here: [http://balusc.blogspot.com/2007/09/objects-in-hselectonemenu.html].
    I would like to load it form DB...That's a bit too expensive for less or more static data.
    Another solutions are:
    - SelectItem should contain address.id instead of address. Than no converter is need. My ManagedBean is reposnsible for translating ids do entities. Works but primitive.JSF can't help that HTTP/HTML only understands Strings (by the way, primitives are also already implicitly converted by EL, you only don't know that).
    - Converter is created by factory method of Managed Bean. MB sets address list to the converter while creating it. List shouldn't be huge if it is used in GUI.
    drawback: loading list in BB twice because converter is used while rendering and while decoding.
    - In converter try to possess MB that has EJB and call method that reutrns entities, sth like this: facesContext.getApplication().getELResolver()...Reloading static data on every request makes als no sense.
    Retoric question: what for are useful JSF Converters?To convert between Object and String, so that it can be passed through HTTP request/response and displayed/taken in HTML.

  • JSF Converter - bug

    When J associate my converter to HtmlDataTable(h:dataTable) in JSF(JSP) page in 'Design' tab appear problems:
    1) in dataTable there isn't any column visable
    2) everything below dateTable in same Panel Grid aren't visable
    All this affect only 'Design' tab. In 'Source' tab everything is OK and when J run application everithing work like it should.
    Is this bug or can be fixed somehow?

    Hi.
    J solve the problem partly and here is the problem and solution:
    Problem - JDeveloper 10.1.3 have problem in showing table when code look like this:
    <h:dataTable width="350" value="#{infoBean.popular}" var="popular_">
    <h:column>
    <f:facet name="header">
    <h:panelGroup>
    <h:commandLink action="POPULAR">
    <h:outputText value="Najpopularnije"/>
    </h:commandLink>
    </h:panelGroup>
    </f:facet>
    <h:commandLink>
    <h:outputText value="#{popular_}" converter="ProductTitle"/>
    </h:commandLink>
    </h:column>
    </h:dataTable>
    Solution - When J change code to this 'Design' tab shows the table but not the text in 'outputText'(here #{popular_}):
    <h:outputText value="#{popular_}">
    <f:converter converterId="ProductTitle"/>
    </h:outputText>
    Please try this!

  • JSF Converter Error

    Hi, I have the following:
    JSF 1.2 RI
    Sun App Server 9 Update 1 Patch 1
    Models:
    public interface Model {
      int getId();
      String getName();
    public class Model1 implements Model {
      public int getId() {
        return 1;
      public String getName() {
        return "One";
    public class Model2 implements Model {
      public int getId() {
        return 2;
      public String getName() {
        return "Two";
    Controller:
    public class TestController {
      private Model model;
      private List<Model> models;
      public TestController() {
        models = new ArrayList<Model>();
        models.add(model = new Model1());
        models.add(new Model2());
      public Model getModel() {
        return model;
      public void setModel(Model model) {
        this.model = model;
      public List<SelectItem> getModels() {
        List<SelectItem> list = new ArrayList<SelectItem>();
        for (Model model : models)
          list.add(new SelectItem(model, model.getName()));
        return list;
      public Model findModel(int id) {
        for (Model model : models) {
          if (model.getId() == id)
            return model;
        return null;
    Converter:
    public class ModelConverter implements Converter {
      public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String string) {
        TestController controller = (TestController) facesContext.getExternalContext().getSessionMap().get("testController");
        return controller.findModel(Integer.parseInt(string));
      public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object object) {
        return String.valueOf(((Model) object).getId());
    View:
    <%@ page contentType="text/html" %>
    <%@ page pageEncoding="UTF-8" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
      <title>Test JSF</title>
    </head>
    <body>
    <f:view>
      <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
      <h1>Test JSF</h1>
      <h:form>
        <h:panelGrid columns="2">
          <h:outputText value="Model:"/>
          <h:selectOneMenu value="#{testController.model}">
            <f:selectItems value="#{testController.models}"/>
          </h:selectOneMenu>
        </h:panelGrid>
      </h:form>
    </f:view>
    </body>
    </html>
    faces-config.xml:
    <?xml version='1.0' encoding='UTF-8'?>
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
                  version="1.2">
      <converter>
        <converter-for-class>com.test.model.Model</converter-for-class>
        <converter-class>com.test.converter.ModelConverter</converter-class>
      </converter>
      <managed-bean>
        <managed-bean-name>testController</managed-bean-name>
        <managed-bean-class>com.test.controller.TestController</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    </faces-config>
    The problem:
    When I run the app, JSF throws the following error:
    javax.servlet.ServletException: Cannot convert com.test.model.Model2@ba30aa of type class com.test.model.Model2 to class com.test.model.Model1
    root cause
    java.lang.IllegalArgumentException: Cannot convert com.test.model.Model2@ba30aa of type class com.test.model.Model2 to class com.test.model.Model1Is there any limitation on converters to prevent using a single Converter for a base class (or interface like Model) and subclasses (like Model1 and Model2)?
    I've tried this using JSF 1.1 RI, Apache MyFaces 1.1 and the error is still there.
    Thanks!

    This sounds like Issue 442, which was resolved in 1.2_03. If I recall right, V1 P1 is 1.2_02. Please upgrade JSF to 1.2_04 [2]. The download section has an updater for GlassFish.
    [1] https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=442
    [2] https://javaserverfaces.dev.java.net/servlets/ProjectDocumentList?folderID=7089&expandFolder=7089&folderID=0

  • UIX - JSF converter

    Hi,
    Did anyone succeded in converting BC4J+UIX project into BC4J+JSF? Available converter fails to convert even small project with one page with one table on UIX page...
    Any success stories?
    Leszek

    Hi,
    When I try to run generated jspx page through struts, I get following error in browser:
    500 Internal Server Error
    java.lang.IncompatibleClassChangeError
    at oracle.cabo.share.xml.ParseErrorUtils.getErrorMessage(Unknown Source)
    at oracle.cabo.share.xml.ParseErrorUtils.log(Unknown Source)
    at oracle.cabo.ui.xml.parse.UINodeParser._parseBinding(Unknown Source)
    etc.
    I run it through struts because converter puts on struts my simple page. It doesn't put it on faces-config. However even when I try to run it through faces (I change url in browser by adding 'faces/' and changing extension from '.do' to '.jspx' I still get an error:
    500 Internal Server Error
    javax.faces.el.EvaluationException: com.sun.faces.el.impl.ElException: No function is mapped to the name "ctrl:createSortableHeaderModel"
         at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:188)
         at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154)
         at oracle.adf.view.faces.bean.FacesBeanImpl.getProperty(FacesBeanImpl.java:55)
    I think that converted page shouldn't contain el expressions that are used to create sortable table headers.
    Anyway, converter is unable to convert so simple project into working JSF project... so it's not helping us in our work.
    Leszek
    P.S. I've sent simple UIX testcase to you. It's ounconverted so you may do it by yourself to be sure that the problem so not related to wrong conversion method...

  • JSF Converter how to use property in faces-config

    I have made an Converter for my listbox, and it is working.
    Now I want to use a property to change the behavior of the converter.
    My faces-config looks like this:
    <!-- Converters -->     
    <converter>
    <converter-for class>model.PacemakerBranche</converter-for-class>
         <converter-class>cconverter.BrancheConverter</converter-class>
         <property>
              <property-name>test</property-name>
              <property-class>java.lang.String</property-class>
              <default-value>12345</default-value>
         </property>
    </converter>
    I try to set the test property to 12345.
    The setTest(String test) is not set.
    What am I doing wrong??
    My converter looks like this:
    public class BrancheConverter implements Converter {
    private String test;
    public String getTest() {
    System.out.println("getTest " + test);
    return test;
    public void setTest(String test) {
    System.out.println("setTest " + test);
    this.test = test;
    public Object getAsObject(FacesContext ctx, UIComponent component,
    String value) {
    return getMgr(ctx).getObject(model.PacemakerBranche.class, new Long(value));
    public String getAsString(FacesContext ctx, UIComponent component,
    Object object) {
    return ((BaseObject) object).getId().toString();
    private Manager getMgr(FacesContext ctx) throws HibernateException {
    return (Manager) FacesContextUtils.getWebApplicationContext(ctx).getBean("manager");
    }

    You can't use f:converter tag for setting properties.
    There are two ways you can use:
    (1) use f:attribute tag
    ex.<h:inputText value="#{...}"/>
      <f:converter converterId="...."/>
      <f:attribute name="test" value="#{...}"/>
    </h:inputText>Note that you should get the value of the attribute from the UIInput component, something like:comp.getAttributes.get("test");(2) develop a custom converter tag.

  • URGENT methode parametres JSF+ SPRING +HIBERNATE

    hello all the world I'm back
    help me plz :
    I want to search an employee from his number I use a search function (String number), I recalled your JSF + hibernate + spring so I'll post the code :
    code of jsp page
    <f:view>
              <h:form id="RechercheEmp">
                   <h:panelGrid columns="2">
                        <h:outputText  value="Entre le Matricule de l'employ� : "/>                    
                        <h:inputText  id="mat" value="#{todoBean.employes.matricule}"/>                    
                    <h:commandButton value="Submit" action="#{todoBean.chercherEmployer?matricule=mat}"/>
                   </h:panelGrid>
                   </h:form>
    </f:view>and code of bean JSF :
    public String chercherEmployer(String matricule) {
            log.debug("#DDD############ createemployesAction()");
            try {
                this.toDoService.chercherToDo(matricule);
                log.debug("#DDD############ checheremployesAction->success");
                return "success";
            } catch (JoTestException e) {
                e.printStackTrace();
                return "failure";
    }in layer service :
    public void chercherToDo(String matricule) throws JoTestException {
            log.debug("#DDD############ saveToDo(toDo) in Service TODO");
            toDoDao.chercherToDo(matricule);
    }and in the layer dao :
    public void chercherToDo(String matricule){
              log.debug("#DDD######### Savetodo in todoDAO : ");
              this.getHibernateTemplate().load(Employes.class, matricule);
    }but i have this probleme :
    javax.servlet.ServletException: #{todoBean.chercherEmployer?matricule=ma'}: javax.faces.el.MethodNotFoundException: chercherEmployer?matricule='mat': jotodo.gui.bean.ToDoBean.chercherEmployer?matricule='mat'()
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)
    cause m�re
    javax.faces.FacesException: #{todoBean.chercherEmployer?matricule=mat}: javax.faces.el.MethodNotFoundException: chercherEmployer?matricule='mat': jotodo.gui.bean.ToDoBean.chercherEmployer?matricule='mat'()
         com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
         javax.faces.component.UICommand.broadcast(UICommand.java:312)
         javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
         javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
         com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
    note La trace compl�te de la cause m�re de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/5.5.20.
    Apache Tomcat/5.5.20

    i changed my page jsp to this :
    <f:view>
              <h:form id="RechercheEmp">
                        <h:outputText  value="Entre le Matricule de l'employ� : "/>                    
                        <h:inputText  id="mat1" value="" />                    
                        <h:commandLink action="#{todoBean.chercherEmployer}">
                          <h:outputText value="Chercher" />
                          <f:param name="mat1" value="#{todoBean.employes.matricule}"/>
                        </h:commandLink>
                   </h:form>
    </f:view>is correct or no ?????????
    but i get again the same error :
    exception
    javax.servlet.ServletException: #{todoBean.chercherEmployer}: javax.faces.el.MethodNotFoundException: chercherEmployer: jotodo.gui.bean.ToDoBean.chercherEmployer()
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)
    cause m�re
    javax.faces.FacesException: #{todoBean.chercherEmployer}: javax.faces.el.MethodNotFoundException: chercherEmployer: jotodo.gui.bean.ToDoBean.chercherEmployer()
         com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
         javax.faces.component.UICommand.broadcast(UICommand.java:312)
         javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
         javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
         com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)Edited by: Maq_Ichigo on Apr 29, 2008 3:09 AM
    Edited by: Maq_Ichigo on Apr 29, 2008 3:19 AM

  • Reusable JSF components - bundling a converter with a text field

    I am trying to create reusable text fields for different types of data (notes, amounts, percentages) that will use a JSF converter to implement formatting.
    Here is what I have done
    - created an application in JDeveloper that contains my components as JSF declarative components
    - created the Converter classes
    - registered the converter classes in faces-config.xml of the reusable components project
    - added my Converters to the inputText fields for each of my declarative components using the property palette
    - deployed the components as a jar file using the ADF Library Jar File archive type
    - created a second application to act as a consumer of the components
    - imported the jar file into the component palette using a file system connection
    - added the jar file to the active project's component library
    - added a converter entry for the converter I am trying to use to this project's faces-config.xml
    - created a consumer jspx page and dragged and dropped the control onto the page
    I put some system.outs in the getAsString() and getAsObject() methods of the converter I am trying to use and they are not output when I run the page. I've also set breakpoints in those methods to see if they are being called.
    I have no indication that my converter is being called.
    Can someone please confirm that what I am trying to do is possible using the declarative components?
    Any insight appreciated.
    Dave

    Actually this is working. I made the incorrect assumption that getAsString() in the converter class would be called on the initial request.
    Another thing I just noticed is that it is not necessary to reference the converter in the faces-config.xml of the consuming project. Not sure how this works, but its a nice feature :)

  • How to custom a conversion error in JSF page in JDeveloper

    According to the book "Core JavaServer Faces" p213 (fifth edition), if I add the following line to messages.properties file, and specifiy it in the faces-config.xml and .jsp file, then the displayed conversion error message should be my tailored one instead of the default. However, I still get the default error message. Besides, I didn't find "CONVERSION" variable in UIInput class. Is the book wrong? And what's the correct way?
    javax.faces.component.UIInput.CONVERSION=Please correct your input

    I didn't choose any special in JDeveloper IDE. I just selected "new" to create a file called "message.properties" and put the line there. I didn't specify converters excepts declaring the type in the Jave Beans. I guess the converting is done by the JSF framework automatically. It must be a JSF converter since I created the page as a JSF page.

  • A new approach to JSF error handling?

    Hi.
    I would like to run an idea by the community to check that I am not being crazy in doing this stuff. I would appreciate any comments, criticism or ideas.
    I was thinking about JSF's error processing mechanism, specifically about how label text gets associated with an input field. So, I am talking about this kind of stuff:
    <h:outputLabel for="firstName" value='#{msgs["applicant.search.firstName"]}: ' />
    <h:inputText id="firstName" value='#{applicantDetailsBackingBean.firstName}' required=�true�/>If the value is not entered into the input field, we will get an error message saying:
    �First Name�: is required.
    So HtmlMessageRenderer has replaced the field id in the FacesMessage with the label text by using the association set up with the 'for' attribute on the label. All of this message "decoration" work happens in the RENDER phase in a centralized location. I see a couple of weaknesses in this approach
    1) It is too late for resolving label text data if the label is inside a data table
    2) JSF establishes associations between label text and the input fields by using the label components to point to their input fields. Although this seems more natural, it limits label text sources to just the label components present on the current page (or whatever is nested under them), which makes it impossible to associate input field messages with label text that does not exist on the page in its entirety.
    Let's look at a couple examples, both of which I ran into in my application:
    1) Consider a situation in which we have a dataTable where every row consists of a student name and an input field for entering their assignment mark. The validation on the input field will be restricted to valid letter grades only. If the user enters an invalid grade, we want them to see an error message of the form: +�The mark entered for <student name> is invalid�.+ Since <student name> is dependent on the row in which the error occurred, this error message is not possible to generate with bare JSF functionality.
    2) Another situation that gets us in trouble is when the label text we want in our error message is not on the page (or not in it's entirety). For example, your page could be split up into multiple parts with those parts having input fields with the same name. We would want the error message to include the page part as well as the field name. This is not easily achieved with the bare JSF functionality.
    So to generalize, any situation where a label component with a static value throughout the lifecycle is not available will cause difficulty.
    Please correct me if I am wrong on any of these points.
    Since in my app I had a lot of complicated pages to deal with, I solved my difficulties by writing a very simple framework that I called Message Decorator Framework (MDF). It enabled me to easily construct much more detailed error messages than what the standard JSF approach seems to allows for. MDF provides a mechanism to specify the label text to be applied to a validation or a conversion message by either a literal, an el expression or via an id of another ValueHolder and all of these work in data tables.
    The idea is a s such, and this is what i would like your opinion on:
    MDF provides more flexible message decoration by adapting the opposite approach to the one used by the JSF:
    1) Message decoration is decentralized. MDF wraps converters and validators on individual input fields and performs message text replacement right on the spot in the PROCESS_VALIDATIONS phase, when all of the pertinent data for resolving the label text is still available.(i.e the components in data tables would still have the correct values for the current row being validated)
    2) The label text to be used is specified by the input field, not the label. This allows the developer to reference any text value, instead of tying them to a specific label component.
    Pictures are better than words, so here is an architectural diagram:
    http://www.imagehosting.com/out.php/i1259440_ArchitectureDiagram.png
    The framework consists of two main classes, ConverterMessageDecorator and ValidatorMessageDecorator. I will just talk about the converter part, b/c the validator part is very similar but wraps a list of validators instead of one converter.
    So ConverterMessageDecorator is a JSF converter. Its purpose is to wrap the converter that is going to do the actual conversion work and decorate the FacesMessage inside ConverterException if one was thrown.
    The converter to wrap can be either determined automatically based on the type of the value reference of the input field or specified explicitly. This converter decorates the message by replacing all instances of the input field�s id with the resolved label text. The power of this approach is that not only do you get a much more flexible way to specify what the label text is (either fieldLabel or fieldLabelComponent attributes), but now data tables are no longer a problem.
    Here are some usage examples:
    <h:inputText value='#{section33SetupBackingBean.contribution.sampleGatePct}'>
       <md:decorateConverterMessage fieldLabel= '#{msgs["section.34.setup.contribution.initial.sampling.gate.max.size"]}' />
    </h:inputText>
    �etc�
    <h:inputText value='#{section33SetupBackingBean.payment.sampleGatePct}'>
       <md:decorateConverterMessage fieldLabel= '#{msgs["section.34.setup.payment.initial.sampling.gate.max.size"]}' />
    </h:inputText>The two input fields have exactly the same labels on the screen (they are in two different parts of the page), so if we used their respective labels, the error messages would look the same for these two input fields.
    More complicated example:
    <h:dataTable value="#{paymentCalcBackingBean.currentPaymentPercentages}" var="currentPercentage" >
    <h:column>
      <ops:refDataDescription id="provinceLabelTextId" refDataType="provinceStateType"
                code="${currentPercentage.programProvince.provinceStateTypeCode}" />
    </h:column>
    <h:column>
      <h:inputText value="${currentPercentage.federalPercentage}">
    <md:decorateConverterMessage fieldLabelComponent="provinceLabelTextId"  valueRequired="true" >
       <f:converter converterId="ops.PercentageConverter" />
    </md:decorateConverterMessage>
    <md:decorateValidatorMessage fieldLabelComponent="provinceLabelTextId" >
       <f:validator validatorId="ops.PercentageValidator" />
    </md:decorateValidatorMessage>
    </h:column>
    �etc�
    </h:dataTable>This would produce errors shown in this screenshot: http://www.imagehosting.com/out.php/i1259418_Example3.png
    Here is another example that shows off what you can do by referencing other ValueHolders on the page.
    The code is exactly the same as the snippet shown above, but the inputText component is referencing a text box, so the label text is going to be whatever the user types into the text box:
    http://www.imagehosting.com/out.php/i1259467_Example4.png
    Does this approach seem reasonable to people, or am I reinventing the wheel? Please let me know.
    Val

    Try restarting the DTR application and see if the problem persists.

  • Is there a Simple Way to Reformat  Database Text with Custom Converter?

    When a database column contains a string, often the string may be stored in the database in a form that may not be suitable for viewing by the user. It is often interesting to show the user the string after it has been reformatted. Many things including phone numbers, product codes and various other application specific encodings fit into this category. The JSF Converter concept seems to be an ideal place to apply the reformatting via the application of a custom converter. In fact, many of the text books written on JSF refer to the JSF ability to support text reformatting using a custom converter. However, we have not been able to make it work in JSC2_1.
    For example, when a CachedRowSet Table Data Provider is used in a JSC2 application to show tabular data from a database, text columns from the database are automatically bound to StaticText components. Unfortunately, if the developer creates a custom converter and attaches it to the StaticText component, the converter is never called when the object to be converted is already of type String. If the object to be converted is a Date, CLOB or any other type the custom converter will be called - but not for type String. Thus the text is presented to the user directly as stored in the database witout the desired reformatting. The OutputText component on the other hand does appear to support custom converters but there is no possibility within the JSC2 IDE to substitute the OutputText component for the StaticText component in the CachedRowSet Table Data Provider.
    This situation appears to be inconsistent with the JSF specification. Does anyone know if this is a bug or a deliberate design decision or a misuse of the IDE on our part? Last question; has anyone come across a workaround?

    Try using "Examine Document" to remove the OCR output.
    Be well...

  • Convert OutputText's Number into Terabytes

    Hi,
    I have the following requirement where we display the Storage Volume size (for ex:11929649152 bytes) as an output text.
    Do we have any number format component in adf to convert this number (11929649152) into Terabytes.
    Thanks,
    Kiran

    Create a new custom jsf converter for your requirement.
    http://download.oracle.com/docs/cd/B31017_01/web.1013/b28967/web_val006.htm
    Regards,

  • Getting an error while validating with the help of domain

    This is strange. I am validating an email address column in employees table by creating a domain and then associating it with the email column in the table. This is the code
        protected void validate() {
            //  ### Implement custom domain validation logic here. ###
            int atpos = mData.indexOf('@');
            int dotpos = mData.lastIndexOf('.');
            if (atpos > -1 || dotpos > -1) {
                throw new DataCreationException(null, "Invalid Email Address", null);
        }But while committing records, I am receiving the following error:
    Cannot convert testmailid of type class java.lang.String to class model.common.DomainEmail
    Can anyone help me?
    Oh yes, I am using JDev 11.1.2.3

    I suspect that you are using an <af:inputText> with no converter for entering the email on the page. The purpose of a converter would be to convert the String value entered by the user in the field to another datatype (e.g. to model.common.DomainEmail type) which is expected by the model layer (e.g. by the target VO attribute). If there is no such converter, JSF does not perform any datatype conversion and it tries to assign the java.lang.String value to the VO attribute (which is of model.common.DomainEmail datatype), so a type casting error occurs. If that is the case, then you should implement and attach a proper JSF converter to the <af:inputText> component.
    Dimitar

  • JDev 10.1.3 how to invoke oc4j_remote_deploy.jar from command line?

    Hi, does anyone know how to invoke the JDev 10.1.3 oc4j_remote_deploy.jar from the command line? We have it working for 10.1.2, for automated deployment scripts.
    If I try the same thing for 10.1.3, I get an error.
    See below my command line and the output.
    I think the error is in the Oc4jDcmServlet URL, the format seems to have changed from 10.1.2 to 10.1.3.
    I tried to reverse-engineer by using an HTTP tracer, but that did not help.
    Any help would be much appreciated.
    Regards, Maarten Brugman
    ======================== command line: ==================
    "C:\j2sdk1.4.2_09\bin\java.exe" -Djava.protocol.handler.pkgs=HTTPClient -jar C:\jdev-work\ebrp-new\ear\target\installer\oc4j_remote_deploy.jar http://lnvx0027:29805/Oc4jDcmServletAPI/ oc4jadmin ***** listApplications /oracle/oaedv03/oracle/oas/10.1.3/ontwj2e1013 UNDEFINED UNDEFINED OC4J_OEBRP
    ============ output: ====================================
    Initializing log
    Servlet interface for OC4J DCM commands
    Command timeout defined at 600 seconds
    Executing DCM command...
    Executing command listApplications /oracle/oaedv03/oracle/oas/10.1.3/ontwj2e1013
    UNDEFINED UNDEFINED OC4J_OEBRP
    Command = LISTAPPLICATIONS
    Opening connection to Oc4jDcmServlet
    Setting userName to oc4jadmin
    Sending command to DCM servlet
    **** Could not check HTTP response code
    ** Thread[main,5,main] ** Fri May 11 17:18:13 CEST 2007 ** ** EXCEPTION: java.
    net.SocketException: Unexpected end of file from server
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:822)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:711)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:820)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:711)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:635)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:272
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmClient.isHttpResponseOk(Unknow
    n Source)
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmClient.sendCommand(Unknown Sou
    rce)
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmCommand.execute(Unknown Source
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmCommand.listApplications(Unkno
    wn Source)
    at oracle.j2ee.tools.remote_deploy.Oc4jDcmMain.main(Oc4jDcmMain.java:71)
    #### HTTP response is NOT ok
    Closing connection to Oc4jDcmServlet
    #### DCM command did not complete successfully (-1)
    #### HTTP return code was -1
    ============ end output =================================

    In my opinion, you will succeed in handling linefeeds in output texts by using an <tt><af:outputFormatted></tt> tag in conjuction with a JSF converter that replaces the linefeeds with a <tt>&lt;br></tt> tag in the text. You will have to implement a custom converter class (this is quite simple, see below) and to set it to the <tt>converter</tt> attribute of the <tt><af:outputFormatted></tt>. The converter class should look like:
    public class MyLinefeedConverter implements javax.faces.convert.Converter
      public MyLinefeedConverter() {
      public Object getAsObject(FacesContext context, UIComponent component, String value) {
        return value;
      public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value==null) return "";
        if (value instanceof String) return ((String)value).replace("\n", "<br>");
        return value.toString();
    }In this way the linefeeds in your text values will be replaced by <tt>&lt;br></tt>, which will be rendered by the corresponding <af:outputFormatted> tag as line breaks.

  • DropDown in each table row

    Hi,
    using ADF BC and JSF, I'm not able to display drop down in each row like described in Steve Muench screencast if the ID field is DBSequence. When it's set to Number everything works well, but if I change it to DBSequence I get WARNING: Could not find selected item matching value "22" in CoreSelectOneChoice[UIXEditableFacesBeanImpl, id=_id4]... I have to use DBSequence, because in other pages I'm inserting rows in that table. I can create another entity and view but that's not a good solution. Any suggestions.
    Thanks in advance,
    Tomislav.

    Thanks Kuba,
    I've never used custom converters so I'm lost. I'm trying to follow this example http://www.oratransplant.nl/2007/05/08/custom-jsf-converter-to-display-minutes-as-hhmm/
    but so far without success.
    this is my converter class:
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    import javax.faces.convert.ConverterException;
    import oracle.jbo.domain.DBSequence;
    import oracle.jbo.domain.Number;
    public abstract class CustomConverter implements Converter {//I had to create abstract class I get error if class is not abstract
    public CustomConverter() {
    public Object getAsObject(FacesContext facesContext,
    UIComponent uiComponent, DBSequence dbsequence) {
    try {
    Number number = dbsequence.getSequenceNumber();
    return number;
    } catch (Exception e) {
    throw new ConverterException(e);
    My faces-config.xml:
    <managed-bean>
    <managed-bean-name>customConverter</managed-bean-name>
    <managed-bean-class>konzum.hr.inventar.view.utils.CustomConverter</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    <converter>
    <converter-id>customConverter</converter-id>
    <converter-class>konzum.hr.inventar.view.utils.CustomConverter</converter-class>
    </converter>
    I cannot add converter to af:selectItem only before or after, so how should I apply converter to af:selectItem and is my approach ok or not.
    Thanks in advance,
    Tomislav.

Maybe you are looking for

  • New internal hard drive not recognized at all!

    Hello everybody! I really need your help. I tried to upgrade my internal 120gb drive to a Western Digital wd2500bevs. But when I start my Macbook with the Leopard DVD neither the System Profiler nor the Disk Utilities Program recognize the drive for

  • Envelope missing in SOAP message header (SAP XI Extension)

    I have scenario where in I am sending a file from XI to PCK. BUt i am getting a following error. <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> - <!--  Call Adapter   --> - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="

  • DB Experts----Oracle 9i Installation Stops after 17%

    Hi, I have a Linux 64 bit Server Running Oracle 10gR2 and need to install a Oracle 9i database as one of programs that we have purchased only works with Oracle 9i. I have downloaded the Oracle 9i installation instructions and applied the relevant pat

  • Can't open start menu or search on build 10061

    This seems to happen after each build update, and it is usually fixed by the app-cache repair Get-appxpackage -all *shellexperience* -packagetype bundle |% {add-appxpackage -register -disabledevelopmentmode ($_.installlocation + "\appxmetadata\appxbu

  • Black color issue...

    Hi. I'm using Ai CS6 64bit now on windows 8, and I have a problem with the black and grey colors, because they look like brown variations...In the past I hadn't similar problems, but recently I changed my notebook to an Asus KB56, from Acer. Can some