Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
3 replies Latest Post - ‏2011-04-05T00:24:04Z by SystemAdmin
dan83
dan83
4 Posts
ACCEPTED ANSWER

Pinned topic I'm not able to insert a new component

‏2011-03-31T15:55:31Z |
Hello,

I have a table that I have defined wit <xf:repeat> after I have defined a template and a button to add a new row to this table that in the same time open a panel in order to define all the values for this new row and at the end of the page you have e button OK to save it (i don't want for now to come back to the server but just to modify the xml that i have) I attached to you a draft about an xform file that I'm composing

in particular you can search in the code the ADD button

<xf:trigger> <xf:label>New Point Of Reference</xf:label> <xf:action> <xf:insert  at=
"index('ri')" position=
"after" origin=
"instance('templateRefPoint')" context=
"/RefPoints"/> <xf:toggle case=
"showTab" ev:event=
"DOMActivate" /> </xf:action> </xf:trigger>


and the button for saving


<xf:trigger class=
"orderListAddTrigger"> <xf:label>OK</xf:label> <xf:hint>Adds a 

new point of reference</xf:hint> <xf:action ev:event=
"DOMActivate"> <xf:setvalue ref=
"instance('templateRefPoint')/@Type"/> <xf:refresh /> </xf:action> </xf:trigger>


Every suggestions about how to organize the code are well accepted!!!
The last thing is that I would like to organize the code importing some structure and customized them, I want to say a sort of template how can i perform it in xform avoiding to write the long file without the reusability of components ?

Thank you
Updated on 2011-04-05T00:24:04Z at 2011-04-05T00:24:04Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    265 Posts
    ACCEPTED ANSWER

    Re: I'm not able to insert a new component

    ‏2011-04-01T02:49:30Z  in response to dan83
    Dan,

    First, in your first snippet above, the ev:event="DOMActivate" should be on the <xf:action>, not the <xf:toggle>. Otherwise no action might run, or just the toggle might run, depending on the XForms implementation.

    In the second snippet, do you really need that refresh? I don't think you should.

    This being said, I am not sure to understand your question. You are using a template for the "row" you insert, which comes from instance('templateRefPoint'). Do you feel you have code duplication in your XForms? Regarding a component system for XForms, Orbeon Forms implements XBL, so you can write and reuse components, and other implementations might have other solution to this problem.

    Alex
    --
    Orbeon Forms - Web 2.0 Forms, open source, for the Enterprise
    http://www.orbeon.com/
  • dan83
    dan83
    4 Posts
    ACCEPTED ANSWER

    Re: I'm not able to insert a new component

    ‏2011-04-01T08:26:46Z  in response to dan83
    Hello Alex thank you for your answer.
    I have modified the button in this way:

    I'm not able to see my new row added to the table I put you the essential element here

    
    <xf:model> <xf:instance id=
    'i-instance'> ... (it
    's the instance that I have attached in the previous message, thatone imported with @model) </xf:instance>   <xf:instance id=
    "templateRefPoint"> <RefPoint Type=
    "" LocationCode=
    "" DirectionFromHotel=
    "" Longitude=
    "" Name=
    "" Rank=
    "" Description=
    "" ReferenceCategory=
    "" DistanceUnit=
    "" Latitude=
    "" AttractionCategory=
    "" Distance=
    ""> </RefPoint> </xf:instance> ...   <!-- Description --> <xf:bind id=
    "refPoint" nodeset=
    "instance('i-instance')/RefPoint"> <xf:bind id=
    "locType" nodeset=
    "@Type" required=
    "true()" type=
    "xs:string"/> <xf:bind id=
    "locCode" nodeset=
    "@LocationCode"  type=
    "xs:string"/> <xf:bind id=
    "locName" nodeset=
    "@Name"  type=
    "xs:string"/> <xf:bind id=
    "dirFromHotel" nodeset=
    "@DirectionFromHotel" required=
    "true()"/> <xf:bind id=
    "distance" nodeset=
    "@Distance" /> <xf:bind id=
    "distanceUnit" nodeset=
    "@Distance" type=
    "xs:string"/> <xf:bind id=
    "description" nodeset=
    "@Description"  type=
    "xs:string"/> </xf:bind> </xf:model> </head> <body>   <!-- I would like to add to 
    
    this table the 
    
    new row --> <xf:repeat id=
    "repeatid" bind=
    "refPoint" appearance=
    "compact" class=
    "orderListRepeat" index=
    'ri'> <xf:output bind=
    "locName"> <xf:label>Location Name</xf:label> </xf:output> <xf:output bind=
    "locType"> <xf:label>Location Type</xf:label> </xf:output> <xf:output bind=
    "distance"> <xf:label>Distance</xf:label> </xf:output> <xf:output bind=
    "distanceUnit"> <xf:label>Distance Unit</xf:label> </xf:output> </xf:repeat>   !--button to add the empty 
    
    new section to the xml and to open the 
    
    new section to fill the values --> <xf:trigger> <xf:label>New Point Of Reference</xf:label> <xf:action ev:event=
    "DOMActivate"> <xf:insert  at=
    "last()" position=
    "after" origin=
    "instance('templateRefPoint')" context=
    "instance('i-instance')" /> <xf:toggle  case=
    "showTab" /> </xf:action> </xf:trigger>   <!--This is the section opened in order to insert the information about the row 
    
    for now I post you only the Type but there are also others that 
    
    for now I have commented-->   <xf:switch> <xf:
    
    case id=
    "case-1" selected=
    "true"> <xf:group> <xf:label>Add Point of Reference</xf:label> <xf:select1 ref=
    "instance('templateRefPoint')/@Type"> <xf:label class=
    "contactsRepeatHeader">Localization Type</xf:label> <xf:itemset nodeset=
    "instance('values')/LocalizationTypes/item"> <xf:label ref=
    "."/> <xf:value ref=
    "."/> </xf:itemset> </xf:select1> .... </xf:group>   <!--button to set value of the attribute aboute RefPoint section previously added in the XML --> <xf:trigger class=
    "orderListAddTrigger"> <xf:label>OK</xf:label> <xf:hint>Adds a 
    
    new point of reference</xf:hint> <xf:action ev:event=
    "DOMActivate"> <xf:setvalue ref=
    "instance('templateRefPoint')/@Type"/> </xf:action> </xf:trigger>
    

    I hope that now the fondamentl component are more clear

    thank you
    Daniele
    • SystemAdmin
      SystemAdmin
      265 Posts
      ACCEPTED ANSWER

      Re: I'm not able to insert a new component

      ‏2011-04-05T00:24:04Z  in response to dan83
      Daniele,

      I put all of this in a stand-alone file (see attached), tried to run this on Orbeon Forms, and the insertion is happening just fine for me. So this might be an issue with the XForms implementation you are using, and you might want to post your question in a forum dedicated to that product.

      Alex
      --
      Orbeon Forms - Web 2.0 Forms, open source, for the Enterprise
      http://www.orbeon.com/