Dynamic datatable in custom component

hi all,
i'm working on a custom jsf component and this component will create a datatable dynamically. (you can see component details from http://www.jroller.com/page/hasant?entry=creating_dynamic_datatable_inside_of AND http://www.jroller.com/page/hasant?entry=jsf_question_for_community_what)
the question is; when i want to add a selection column(dynamically), how can i handle its selected values?
i mean, if i have created this datatable in a page with designer, i would bind an Integer[] to that selection column's checkboxes. But i have to add this selection column dynamically from my component. So, how can i GET and SET the selection columns values. Since this is a custom component, there is no backing bean for value binding to this component.
when i resolve the request param string to get the selected rows, it's working(=i can see the selected rows somehow..) but, i can not set that values again while encoding that column after a submit.
here is my row selection column encoding code;
     private void addSelectionColumnToTable(FacesContext context, UIData table) {
          UIColumn column = new UIColumn();
          HtmlInputRowSelect rowSelect = new HtmlInputRowSelect();
          rowSelect.setId("rowSelect1");
          rowSelect.setStyleClass("inputRowSelect");
          rowSelect.setValue(m_selectedRows);
          column.getChildren().add(rowSelect);
          table.getChildren().add(column);
     }In the code above, rowSelect.setValue(m_selectedRows); part not effecting anyhing. m_selectedRows variable includes row numbers(in an Integer array) that i want to see as selected.
any solution/recommendation?

Well if you are still interested in using a text component
instead of a Button the way you would go about this is using
textWidth. Here's how I've done it before using a text / label
whatever you want that shows text.
// => Set our text we got from database
myText.text = "This is the text I got from the DB";
// => Validate it so that way we make sure we get right
numbers
myText.validateNow();
// => Find out how wide our text really is.
var textWidth:Number = myText.textWidth
// => Reset the width of our text component and add 20 for
a little buffer
myText.width = textWidth + 20;
Now my suggestion is if your going to be dynamically creating
these on the fly from a database call you throw it into a method /
class and have that do all the work for you so all you have to do
is pass the text to it and it resizes itself based on the example
above.

Similar Messages

  • Dynamic attribute in a custom component

    has anybody tried generating an attribute dynamically in a custom component
    e.g
    <cx:inputText value="" foo="footest"/>
    where foo is not defined in the custom inputtexttag.java
    can we have a hashmap which stores all the unknown attributes into the hashmap upon loading and then handle it in the setproperties

    can we have a hashmap which stores all the unknown
    attributes into the hashmap upon loading and then
    handle it in the setpropertiesJSF's UIComponent has a function of generic attributes.
    Use <f:attribute>.
    <cx:inputText value="" foo="footest"/> Anyway, if you want to use the syntax like this, you should provide a custom
    tag handler which has a setFoo() method and whose setProperties() method
    copys the value to the corresponding (generic) attribute of the component.

  • Best strategy for variable aggregate custom component in dataTable

    Hey group, I've got a question.
    I'd like to write a custom component to display a series of editable Things in a datatable, but the structure of each Thing will vary depending on what type of Thing it is. So, some Things will display radio button groups (with each radio button selecting a small set of additional input elements, so we have a vertical array radio buttons and beside each radio button, a small number of additional input elements), some will display text-entry fields, and so on.
    I'm wondering what the best strategy for tackling this sort of thing is. I'm sort of thinking I'll need to do something like dynamically add to the component tree in my custom component's encodeBegin(), and purge the extra (sub-) components in encodeEnd().
    Decoding will be a bit of a challenge, maybe.
    Or do I simply instantiate (via constructor calls, not createComponent()) the components I want and explicitly call their encode*() and decode() methods, without adding them to the view tree?
    To add to the fun of all this, I'm only just learning Faces (having gone through the Dudney book, Mastering JSF, and writing some simpler custom components) and I don't have experience with anything other than plain vanilla JSP. (No EJB, no Struts, no Tapestry, no spiffy VisualDevStudioWysiwyg++ [bah humbug, I'm an emacs user]). I'm using JSP 2.0, JSF 1.1_01, JBoss 4.0.1 and JDK 1.4.2. No, I won't upgrade to 1.5 (yet).
    Any hints, pointers to good sample code? I've looked at some of the sample code that came with the RI and I've tried to navigate the JSF Blueprints stuff, but I haven't really found anything on aggregating components into a custom component. Did I miss something obvious?
    If this isn't a good question, please let me know how I can sharpen it up a bit.
    Thanks.
    John.

    Hi,
    We're doing something very similar. I had a look at the Tomahawk Date component, and it seems to dynamically created InputText components in the encodeEnd(). However, it doesn't decode this directly (it only expects a single textual value). I expect you may have to check the request yourself in decode().
    Other ideas would be appreciated, though - I'm still new to JSF.

  • Getting dynamic id of a component bound to a datatable, using javascript

    Hi....
    I am using Sun Studio Creator to develop a small application.
    I have a problem in getting the dynamic id of a component in Javascript, which is bound to a column of a datatable.
    In the jsp page, I have a datatable and it is bound to a list in the backing bean.The datatable has 2 columns.One column is a checkbox and the other column is a dropdownlist. The values of the checkbox and the dropdown are taken from the list for a button click.The list data are taken from database.Now, I want to enable/disable the dropdownlist according to the check box value(the user checks/unchecks) and I want to do it on the change/onclick of the checkbox.That is, I want to get the dynamic id of the check box in a Javascript. I tried using the j4j idProxy as well. But that also failed to help me.
    In Javascript,
    function changeCheckboxValue() {
    var i = document.getElementById('checkboxStatus').title;
    alert(i);
    This alert message is "undefined".
    In jsp,
    <h:column binding="#{AssignVals.column1}" id="column1">
    <h:selectBooleanCheckbox binding="#{AssignVals.checkbox1}" id="checkbox1"
    onchange="changeCheckboxValue()" value="#{currentRow['status']}">
    <j4j:idProxy id="checkboxStatus" />
    </h:selectBooleanCheckbox>
    </h:column>
    How can I get the dynamic id of the check box in the javascript?
    I don't want to do this in the backing bean, as it causes more server trips.
    Thanks & regards,
    Menaka.

    What about using this in your js script?
    onchange="changeCheckboxValue(this)"
    Names generated by JSF implementation have the format:
    <form>:<component>
    For data table is like:
    <form>:<datatable>:<row #>:<component>
    For example:
    form1:dataTable1:1:outputText1
    You could parse the name of "this" and found what row and form the other component name, for example:
    name = "form1:dataTable1:" + row + outputText1;
    this.form[name].text = "hello";
    Regards.

  • Dynamic visibility for a custom component

    Hi everybody,
    I have implemented dynamic visibility for my component and try to use it with the Xcelsius checkbox.
    At preview my component is visible as the checkbox is checked.
    I unchecked the checkbox then my component is no more visible,  and it is works fine.
    But when I checked the checkbox again, my compoenent doesn't appear any more...
    Any idea ?

    Hi Evan,
    I am developing a component which requires "Dynamic Visibility" property.
    Its an Icon component where I have to bind a value for Icon. (i.e 0-30 Smiley, 31-70 dash, 71-100 Frown)
    The dynamic visibility works fine only when I bind both (Value for Icon,  Dynamic Status) to the same excel cell.
    Looks like Xcelsius wants all the bindings to be done to same cell in the Excel.
    [Here|http://docs.google.com/View?id=dzf62p8_35gc73brzm] is my code for your review.
    Please help me. Your timely respose would be of great help for me.
    Thanks
    Ravi.

  • Problem with inputText in my custom component

    Hi, I have a custom dataTable component that I'm trying to get to work. It has to be a custom component because dataTable doesn't support rowspan, colspan, multi line headers, and a rendered attribute for rows. The problem is, that when I wrap the column tag inside my row tag then the method for the inputText tag never gets called in the UPDATE_MODEL_VALUES phase.
    I'm starting to think that JSF doesn't support 2 levels of tags between the inputText and dataTable. I'm hoping that someone can tell me what I have wrong with my components.
    Here is the JSP snippet.
    <cjsf:rptTable>
         <cjsf:data id="dataTable1" value="#{allAuthUser.tableRows}" var="myTableRow1">
              <cjsf:row>
                   <cjsf:col>
                        <h:inputText id="tableTestFld" value="#{myTableRow1.testFld}" size="5" maxlength="5"/>
                   </cjsf:col>
              </cjsf:row>
         </cjsf:data>
    </cjsf:rptTable>Here is what it renders. It looks to me like everything renders fine. So I'm guessing that there is something in a component that is causing JSF during the life cycle to not be able to process correctly.
    <table>
         <tbody>
              <tr>
                   <td><input id="tblmaintForm:body:dataTable1_0:tableTestFld" name="tblmaintForm:body:dataTable1_0:tableTestFld" type="text" value="" maxlength="5" size="5"/></td>
              </tr>
              <tr>
                   <td><input id="tblmaintForm:body:dataTable1_1:tableTestFld" name="tblmaintForm:body:dataTable1_1:tableTestFld" type="text" value="" maxlength="5" size="5"/></td>
              </tr>
              <tr>
                   <td><input id="tblmaintForm:body:dataTable1_2:tableTestFld" name="tblmaintForm:body:dataTable1_2:tableTestFld" type="text" value="" maxlength="5" size="5"/></td>
              </tr>
         </tbody>
    </table>Note: If I leave off the row tag it renders the same way except of course the <tr> and </tr> tags are missing. If I do this, then the backing method for the inputText tag is called and everything works fine. Why doesn't it work with the row tag in place?
    Here are the components:
    public class UIRptTable extends UIComponentBase {
         public UIRptTable() {
              setRendererType("tblmaint.rptTableRenderer");
         public String getFamily() {
              return "javax.faces.Output";
    public class UIRptTableData extends HtmlDataTable {
         public UIRptTableData() {
              setRendererType("tblmaint.rptTableDataRenderer");
         public String getFamily() {
              return "javax.faces.Data";
    public class UIRptTableRow extends UIOutput {
         public UIRptTableRow() {
              setRendererType("tblmaint.rptTableRowRenderer");
         public String getFamily() {
              return "javax.faces.Output";
    public class UIRptTableCol extends UIColumn {
         public UIRptTableCol() {
              setRendererType("tblmaint.rptTableColRenderer");
         public String getFamily() {
              return "javax.faces.Column";
    }Here is part of the faces-config file in case you need it.
    <!-- Components -->
    <component>
         <component-type>tblmaint.rptTable</component-type>
         <component-class>com.monsanto.ag_it.fieldops.aim.tblmaint.component.UIRptTable</component-class>
    </component>
    <component>
         <component-type>tblmaint.rptTableData</component-type>
         <component-class>com.monsanto.ag_it.fieldops.aim.tblmaint.component.UIRptTableData</component-class>
    </component>
    <component>
         <component-type>tblmaint.rptTableRow</component-type>
         <component-class>com.monsanto.ag_it.fieldops.aim.tblmaint.component.UIRptTableRow</component-class>
    </component>
    <component>
         <component-type>tblmaint.rptTableCol</component-type>
         <component-class>com.monsanto.ag_it.fieldops.aim.tblmaint.component.UIRptTableCol</component-class>
    </component>
    <!-- Render Kits -->
    <render-kit>
         <renderer>
              <component-family>javax.faces.Output</component-family>
              <renderer-type>tblmaint.rptTableRenderer</renderer-type>
              <renderer-class>com.monsanto.ag_it.fieldops.aim.tblmaint.renderer.RptTableRenderer</renderer-class>
         </renderer>
    </render-kit>
    <render-kit>
         <renderer>
              <component-family>javax.faces.Data</component-family>
              <renderer-type>tblmaint.rptTableDataRenderer</renderer-type>
              <renderer-class>com.monsanto.ag_it.fieldops.aim.tblmaint.renderer.RptTableDataRenderer</renderer-class>
         </renderer>
    </render-kit>
    <render-kit>
         <renderer>
              <component-family>javax.faces.Output</component-family>
              <renderer-type>tblmaint.rptTableRowRenderer</renderer-type>
              <renderer-class>com.monsanto.ag_it.fieldops.aim.tblmaint.renderer.RptTableRowRenderer</renderer-class>
         </renderer>
    </render-kit>
    <render-kit>
         <renderer>
              <component-family>javax.faces.Column</component-family>
              <renderer-type>tblmaint.rptTableColRenderer</renderer-type>
              <renderer-class>com.monsanto.ag_it.fieldops.aim.tblmaint.renderer.RptTableColRenderer</renderer-class>
         </renderer>
    </render-kit>I sure hope that someone can help me out. Please let me know if you need any additional information.
    Thanks,
    Ray

    Hi, Ray!
    1) I was trying to put a button in the column header (for sorting) and I couldn't get that to work. That involved the >colhdr tag. I got that to work but I don't remember the fix. I'll look it up and reply back with that when I can.Dealing the first part of your trouble, you need NOT a custom component.
    I have looked through the implementation of RepeaterRenderer, as you advised me, and found that the multi-header possibility is included in the implementation of dataTable control.
    The code below is the part of source of repeater.jsp with only change:
    <d:data_repeater> &#61664; <h:dataTable>
    And it works fine.
    <h:dataTable id="table"
    binding="#{RepeaterBean.data}"
         rows="5"
    value="#{RepeaterBean.customers}"
    var="customer">
    <f:facet name="header">
    <h:outputText value="Customer List"/>               <!� First Header row -- >
    </f:facet>
    <h:column>
    <%-- Visible checkbox for selection --%>
    <h:selectBooleanCheckbox
    id="checked"
    binding="#{RepeaterBean.checked}"/>
    <%-- Invisible checkbox for "created" flag --%>
    <h:selectBooleanCheckbox
    id="created"
    binding="#{RepeaterBean.created}"
    rendered="false"/>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Account Id"/>               <!�Second Header row -- >
    </f:facet>
    <h:inputText id="accountId"
    binding="#{RepeaterBean.accountId}"
    required="true"
    size="6"
    value="#{customer.accountId}">
    </h:inputText>
    <h:message for="accountId"/>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Customer Name"/>               <!�Second Header row -- >
    </f:facet>
    <h:inputText id="name"
    required="true"
    size="50"
    value="#{customer.name}">
    </h:inputText>
    <h:message for="name"/>
    </h:column>
    <h:column>
    <f:facet name="header">                    <!�Second Header row -- >
    <h:outputText value="Symbol"/>
    </f:facet>
    <h:inputText id="symbol"
    required="true"
    size="6"
    value="#{customer.symbol}">
    <f:validateLength
    maximum="6"
    minimum="2"/>
    </h:inputText>
    <h:message for="symbol"/>
    </h:column>
    <h:column>
    <f:facet name="header">                    <!�Second Header row -- >
    <h:outputText value="Total Sales"/>
    </f:facet>
    <h:outputText id="totalSales"
    value="#{customer.totalSales}">
    <f:convertNumber
    type="currency"/>
    </h:outputText>
    </h:column>
    <h:column>
    <f:facet name="header">                    <!�Second Header row -- >
    <h:outputText value="Commands"/>
    </f:facet>
    <h:commandButton id="press"
    action="#{RepeaterBean.press}"
    immediate="true"
    value="#{RepeaterBean.pressLabel}"
    type="SUBMIT"/>
    <h:commandLink id="click"
    action="#{RepeaterBean.click}"
    immediate="true">
    <h:outputText
    value="Click"/>
    </h:commandLink>
    </h:column>
    </h:dataTable>
    You may have a look at HTML source to prove that dataTable is already what you need:
    <table id="myform:table">
    <thead>
    <tr><th colspan="6" scope="colgroup">Customer List</th></tr>
    <tr>
    <th scope="col"></th>
    <th scope="col">Account Id</th>
    <th scope="col">Customer Name</th>
    <th scope="col">Symbol</th>
    <th scope="col">Total Sales</th>
    <th scope="col">Commands</th>
    </tr>
    </thead>
    <tbody>
    2.) The second trouble is still unsettled as previously. Right now I have different task at my job, and I can�t continue investigation of this problem.
    But when you find smth., please let me know. I�ll be very grateful.
    Regards,
    Oleksa Stelmakh

  • Unable to Edit the View in Custom Component

    Hi Experts,
    Please help me to resolve this issue !
    I am unable to lock the BOL Entity in my custom component using BTAdminH. I have written the below code in the Edit event Handler for Edit Button. The lr_entity->lock( ) condition statement is getting false and it is skipping the "set_view_editable( me )." code statement. Why??
    This is code excerpt that I have taken from edit button of the BP_HEAD/AccountViewSet and altered to my component/View
    DATA: lr_entity     TYPE REF TO cl_crm_bol_entity,
            lr_controller TYPE REF TO cl_ZVKH8_bspwdcomponent_impl.
      TRY.
          lr_controller ?= me->comp_controller.
          lr_entity ?= lr_controller->typed_context->btadminh->collection_wrapper->get_current( ).
    IF lr_entity IS BOUND.
      IF lr_entity->IS_LOCKED EQ abap_false.
        IF le_entity->IS_CHANGEABLE EQ abap_true.
           IF lr_entity->lock( ) EQ abap_true.
            me->view_group_context->set_view_editable( me ).
           ENDIF.
        ENDIF.
      ENDIF.
    ENDIF.
    and when I directly executed the below code in the Edit event Handler for Edit Button I am receiving the dereferencing NULL value exception. Why in my custom component in many places this happening??
      me->view_group_context->set_view_editable( me ).
    Exception Details
    CX_SY_REF_IS_INITIAL - Dereferencing of the NULL reference
    Method: ZL_ZVKH8_DETAILSEF_IMPL=>EH_ONBACK
    Thanks,
    Bujji

    Hi Summit & NishaNC,
    Thanks for your responses !
    As suggested, I have debugged the code for ->lock( ) method and there are exceptions raised from some methods.
    Method GET_LOCK () -> Method GET_ROOT () ->Method GET_PARENT ()
    At GET_ROOT( ) method i have received an exception
    "Root entity BTAdminH could not be determined" and one more "Entity BTAdminH could not be locked"
    Later when I have checked in MODEL Browser, I found that the BOL object "BTAdminH" for my view is an Access object and not the Root Object.
    Hence, I have a question? Does the locking can be done only for ROOT Objects?
    If this is TRUE then I think this is the major problem with my custom component where even the cross component navigation is also not happening and in many places I am receiving "Dereferencing NULL Value" information.
    Also I have gone through some of the Threads and one information that I found from Sumit Mittal
    1. An access object is an independent entity, has primary keys of its own.
    2. A root object is a special access object that is at the top of the hierarchy based on business rules.
    3. A dependent object's primary keys are supplied by access objects and it's lifetime is bound to them. If the parent object is destroyed, the dependent object is also destroyed.
    4. Search objects are query objects useful for querying root objects
    5. Search result objects - Search objects return the results in the form of a result object together with a relation pointing to the root object.
    6. View objects - ?
    7. Dynamic search objects - Used in advanced search, supports ranges and operators
    Could you please specify in which scenarios we have to go for Access Objects and Root Objects
    Thanks,
    Bujji

  • How to construct the component tree in my custom component?Help!

    Hi, i am writing a custom component like this:
    public class HtmlCategory extends HtmlPanelGrid
         public void processRestoreState(javax.faces.context.FacesContext context,
                java.lang.Object state)
              setColumns(1);
              HtmlCommandLink link=new HtmlCommandLink();
              link.setValue("Let's Bingo");
              MyUtil.setActionListener(context,link,"#{temp.mytest}");
              UIParameter param=new UIParameter();
              param.setName("name");
              param.setValue("Robin!");
              link.getChildren().add(param);
              param.setParent(link);
              getChildren().add(link);
              link.setParent(this);
              super.processRestoreState(context,state);
    }         you see, i want to construct the compont tree at Restore View phase this way,because the structure of the component tree will always be the same, so i don't the user to write extra code.
    But the children of the component are not rendered,the renderer of the HtmlCategory component just extends the HtmlGridRenderer(myfaces) directly,and always calls the "super" methods in the encode methods of the renderer.
    I got a message from the console:
    Wrong columns attribute for PanelGrid id0:id4: -2147483648
    but i have set the columns attribute in the code above, so what's happening? or please give some advice about how to render the component tree by myself in Restore View with the tree constructing code in the custom component class code,just lke the code above.
    Best Regards:)
    Robin

    Well, i don't know if i have got my question clear.
    usually, according to the tags you use in the jsf page, a component tree will be created at the Restore View phase,for example:
    <f:form>
      <h:panelGrid ...........>                         
              <h:dataTable ................>
              </h:dataTable>
       </h:panelGrid>
    </f:form>but because i am writing a component for my web app, all the child components and their attributes are not likely to change. so i want to reduce the tags into one custom tag, and construct the component tree internally by myself.But it is not the case of backing bean.So i wrote the the code in the method:
    public void processRestoreState(javax.faces.context.FacesContext context,java.lang.Object state)as it is shown in my orginal message.But it seems that it is not right way to construct my component tree.So where should i put the code that construct the component tree?Overriding the method :
    public void processRestoreState(javax.faces.context.FacesContext context,java.lang.Object state)is not the right way?
    Best Regards:)
    Robin

  • Advice on creating a tricky custom component

    Hi,
    I'm working on creating a custom component which displays a image at the top of the canvas, and loops through a passed array collection, displaying each row of the array collection in a item renderer. So the component should look like this (see attached image).
    As you can see from this image the header is a image itself, this will differ every instance of the panel, there should be 3 of these panels on the page. Then each row of data is a item renderer displaying the data provided from a array collection of value object. If there are 4 items in this array collection then the panel should show 4 rows, if there are 2 row in the array then the panel will display 2 rows. Also the height of the panel will dynamically change depending on the number of rows to show.
    I was thinking of extending a Canvas component, and then passing in the image URL and trying to load and draw the image dynamically, then I was thinking of using the Drawing API to create the rectangle shape using the drawRoundRectComplex() of the graphics class.
    The problems I see with this is that I don't think the drawn rectangle shape can re-draw itself to show the change in height when more or less row of data need to be be displayed.
    Another option I have been thinking about is extending the Panel class to create my component, this may be better for handling the height resizing, but I'm not sure it can support the look of this component (the header image and the three rounded corners).
    Could anyone give me some advice on what would be the better option for creating this component.
    Thanks
    Stephen

  • Custom component and non-primitive types of attributes

    Dear programmers
    I try to develope a custom UI component that one of its attribute is an ArrayList. For example:
    <productFile:Matrix images="#{MyBean.imagesArray}"/>Unfortuanetly I get the following exception:
    [Unable to convert string &#39;#{MyBean.imagesArray}&#39; to class java.util.ArrayList for attribute images: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager]: org.apache.jasper.JasperException: Unable to convert string '#{MyBean.imagesArray}' to class java.util.ArrayList for attribute images: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager
    The attribute images is an ArrayList in the custom component.
    I have also specifieded it as an ArrayList in the tld file:
    <tag>
           <name>Matrix</name>
           <tag-class>org.sii.productfilejsf.tags.MatrixTag</tag-class>
           <body-content>JSP</body-content>
           <attribute>
                <name>images</name>
                <required>false</required>
                <rtexprvalue>false</rtexprvalue>
                <type>java.util.ArrayList</type>
           </attribute>
      </tag>Does anyone has an idea what can be the problem?
    How can I convert the expression?

    so how will I be able to convert it?Only your converter knows it.
    By the way, is your Matrix component fully completed including its children components?
    If yes, you should know how to implement a converter, or its equivalent code for them.
    For example, in the <h:dataTable> component, if its value attribute points an array of object,
    then it is automatically converted to an appropriate DataModel used by its column children.
    We may need to see your MyBean bean and related code set, if we have enough time.

  • A Custom Component and the JSP source that get's generated

    I'm writing a Custom Component library and I'm at a point where I need to understand how the JSP source that gets generate when my component is dragged from the palete is created and how it relates to the properties I define in the Metadata files.
    In particular I have a component that is an extension of the DataTable component and I'd like to control what get's dropped onto the page when the user drags over my component.
    Don

    See the "Building and Customizing JavaServer Faces Technology Components" technology theme page at http://developers.sun.com/prodtech/javatools/jscreator/reference/themes/buildingjsf/index.html. The Hands-On Examples and "Design-Time API User Guide (pdf)" linked from that page should help.

  • Using Predicate filters in a Custom component

    Hello,
    I have a cusom datagrid component, which gets it's data from a XMLListCollection object. The xmlList is a simple <employess><employe1><fname/><lname/></emloye1></employees>
    I have a text input as a part of this custom component. I am creating a change event on the control to trigger a filter function filterGrid(). I want the frid to dynamically change data as the user types the characters. Currently i have hardcoded my predicate filter to filter the grid whenever the first char matches J. How can i change this to read the chars from the text input.
                private function filterGrid(event:Event):void {
                    if(text1.text!="") {
                        myXMLCollection.filterFunction = filterEmp;
                    }else {
                        myXMLCollection.filterFunction = null;
                    myXMLCollection.refresh();
                private function filterEmp(item:XML):Boolean {
                    var searchResult:XMLList;
                    searchResult = item.(/^J/.test( fname ) );//Help need here
                    trace(searchResult);
                    if(searchResult.length()>0) {
                        return true;
                    return false;
    Thanks,

    I got this to work
    var pattern2:RegExp = new RegExp(text1.text, "i");\
    searchResult = item.(pattern2.test( fname ) || pattern2.test(lname) );
    But have another problem, the regex matches any charater and not the first chars as i type them for example
    IF i have
    John Macey
    Tracy Jordon
    and if i type 'c' in the textnpt i get both John Macey and Tracy Jordon.
    Will dig further,

  • AddChild Not working in a loop with custom component

    Hi,
    I have a custom component 'form component'
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Form xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%">
        <mx:Script>
            <![CDATA[
                import mx.controls.Alert;
                import flash.net.navigateToURL;
                public var documentName:String;
                public var documentLocation:String;
                public var documentDescription:String;
                public var documentLevel:String;
                private function openLink():void
                    var urlRequest:URLRequest=new URLRequest(documentLocation);
                    navigateToURL(urlRequest,"_blank");
            ]]>
        </mx:Script>
        <mx:FormItem width="100%" height="100%" paddingRight="10" borderThickness="10">
            <mx:VBox width="100%" cornerRadius="10" borderThickness="2" borderStyle="solid" borderColor="#D5D2D2">
                <mx:ApplicationControlBar width="100%"  fillAlphas="[1.0, 0.52]" fillColors="[#FFFFFF, #B3CDD9]">
                    <mx:LinkButton id="eachDocumentName" label="Name" click="openLink()" textAlign="left" width="50%" />
                    <mx:Label id="eachDocumentLevel" text="Level" textAlign="right" width="50%"/>
                </mx:ApplicationControlBar>
                <mx:Label id="eachDocumentDescription" width="100%" text="Description" paddingTop="5"  paddingLeft="10"/>
                <mx:Label height="10" width="100%" />
            </mx:VBox>
        </mx:FormItem>
    </mx:Form>
    and I Want to add this component inside a VBox for a loop dynamically like
    Script Code:
    private function showDocuments(event:ResultEvent):void
                    var documentList:ArrayCollection=event.result.root.documents.document;
                    for(var i:int=0;i<documentList.length;i++)
                        var documentName:String=documentList[i].name.toString();
                        var documentDescription:String=documentList[i].description.toString();
                        var documentLevel:String=documentList[i].level.toString();
                        var documentLocation:String=documentList[i].location.toString();
                        createChildForFilePanel(documentName,documentLevel,documentDescription,documentLocation);
                private function createChildForFilePanel(documentName:String,documentLevel:String,documentDescription:Stri ng,documentLocation:String):void
                        Alert.show("function Called");
                        var documentListing:DocumentListing=new DocumentListing();
                        documentListing.percentWidth=100;
                        documentListing.percentHeight=100;
                        documentListing.eachDocumentName.label=documentName;
                        documentListing.eachDocumentLevel.text=documentLevel;
                        documentListing.eachDocumentDescription.text=documentDescription;
                        documentListing.documentLocation=documentLocation;
                        filePanel.addChild(documentListing);
    MX: code
      <mx:VBox id="filePanel" label="File Content" width="100%" height="100%" borderThickness="0" >
          </mx:VBox>
    This is actually Not working.. Am I doing anything wrong. I have included the component in the namespace..
    Thanks In Advance,
    Piyush

    Its working now. The Solution to it what I found was whatever you are Adding To the Parent Component. The Parent Component should be created in the action script.
    Worked for me :-)
    Thanks,
    Piyush

  • Custom component with additional tags

    Hi. I need to write complicated custom JSF component.
    I know how to write simple custom components, and receive String variables from tag attributes e.g.
    https://github.com/devalentino/temp/blob/master/src/main/java/net/monopolyclub/components/component/UserData.java
    But now I need to write custom component with additional tags (for example like dataTable and column tags).
    How can I write such component? How can I receive collections in my component? How can I work with additional tags in my component.
    for example I need something like:
    <m:chat>
         <m:tab value="#{UserList}" />
         <m:message value="#{MesageMap}" />
    </m:chat>
    where UserList - Collection with current users and MessageMap is Map with User as key and message as value.

    Iam using pt:ptdata.joincurrcommunitydata
    here is some code
    <pt:ptdata.joincurrcommunitydata pt:id="menutabsjoin" />
    <pt:logic.foreach pt:var="temp2" pt:data="menutabsjoin">
    <span class="CommunityPage">
    <pt:core.html href="$temp2.url" pt:tag="a">
    <pt:core.html pt:tag="img" src="$temp2.img" alt="$temp2.title" border="0" align="absmiddle" height="$temp2.imgheight"      width="$temp2.imgwidth" />
                        <pt:logic.value pt:value="$temp2.title" />
                             </pt:core.html>
                             </span>
                             </pt:logic.foreach>
    But the URL that is generated is not having the CommunityID, hence it errors out saying object not found.
    Any help would be appreciated?
    Thanks
    kartik

  • Custom component problem

    I wrote a custom component:
    Here is the code for the UIComponent:
    package customcomponents;
    import javax.faces.component.*;
    import javax.faces.context.*;
    import java.util.Vector;
    import jsf.*;
    public class UIEventsTable extends UIComponentBase {
         public String getFamily() {
              return "EventsTable";
         public void encodeEnd( FacesContext context ) throws java.io.IOException {
              Vector<Event> events = (Vector<Event>) this.getAttributes().get("events");
              ResponseWriter writer = context.getResponseWriter();
              writer.startElement("table" , this );
              for( int i = 0 ; i < events.size() ; ++i ) {
                   writer.startElement("tr",this);
                        writer.startElement("td",this);
                             writer.write( events.elementAt(i).getEvent_description() );
                        writer.endElement("td");
                   writer.endElement("tr");
              writer.endElement("table");
    }This is the tag class
    package customcomponents;
    import javax.faces.webapp.*;
    import javax.faces.component.*;
    import java.util.*;
    import jsf.*;
    public class EventsTableTag extends UIComponentTag {
         Vector<Event> events = null;
         public String getRendererType() {
              return null;
         public String getComponentType() {
              return "EventsTable";
         public void release() {
              super.release();
              events = null;
         protected void setProperties( UIComponent component ){
              super.setProperties( component );
              if( events != null )
                   component.getAttributes().put( "events" , events );
         public Vector<Event> getEvents() {
              return events;
         public void setEvents(Vector<Event> events) {
              this.events = events;
    }Taglib descriptor:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
         <tlib-version>1.0</tlib-version>
        <jsp-version>1.2</jsp-version>
        <short-name>d</short-name>
         <uri>http://eventsTable.com/</uri>
        <tag>
             <name>EventsTable</name>
               <tag-class>customcomponents.EventsTableTag</tag-class>
               <body-content>JSP</body-content>
             <attribute>
                  <name>events</name>
             </attribute>
             <attribute>
                  <name>id</name>
             </attribute>
             <attribute>
                   <name>rendered</name>
              </attribute>
              <attribute>
                   <name>binding</name>
              </attribute>
        </tag>
    </taglib>And finally how I invoke the tag
    <d:EventsTable events="#{location.events}" />
    ...Now location.events is a java.util.Vector with the events. But when I use this tag I get following error message:
    Servlet.service() for servlet Faces Servlet threw exception
    org.apache.jasper.JasperException: Unable to convert string "#{location.events}" to class "java.util.Vector" for attribute "events": Property Editor not registered with the PropertyEditorManagerI do not understand why this doesn't work. Because in a "h:dataTable" I can tell the component to use an array as an input. Even more I don't know what a PropertyEditorManager is.
    So how can I pass the vector object to this custom component?

    I have tried with tomcat-6.0.14 and RI 1.2_06-b02-FCS
    <?xml version="1.0" encoding="UTF-8"?>
    <taglib 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-jsptaglibrary_2_1.xsd"
       version="2.1">
       <tlib-version>1.1</tlib-version>
        <short-name>d</short-name>
         <uri>http://eventsTable.com/</uri>
        <tag>
             <name>EventsTable</name>
               <tag-class>customcomponents.EventsTableTag</tag-class>
           <attribute>
               <name>events</name>
             <deferred-value>
                <type>java.util.Vector</type>
             </deferred-value>        
          </attribute>
        </tag>
    </taglib>
    package customcomponents;
    import javax.el.ValueExpression;
    import javax.faces.webapp.*;
    import javax.faces.component.*;
    public class EventsTableTag extends UIComponentELTag {
         private ValueExpression events = null;
         public String getRendererType() {
              return null;
         public String getComponentType() {
              return "EventsTable";
         public void release() {
              super.release();
              events = null;
         protected void setProperties( UIComponent component ){
              super.setProperties( component );
              component.setValueExpression("events", events);
         public void setEvents(ValueExpression events){
              this.events = events;
    }

Maybe you are looking for