Hi Laura ... thanks for the continuing help you are giving!! :) Here is an exhaustive explanation of my situation (both reason and design) ... apologies if it's too verbose but it's meant to illustrate how I have 2 separate Custom Units, and that each of them will be instantiated to take one of two different variations at run-time.
The Reason:
Ok, so I'm doing a PhD on Stigmergy (think ants leaving pheromone trails when finding food) in Web 2.0. It's about users leaving trails in Web sites both intentionally (Marker Based) and unintentionally (Sematectonic). Perfect examples of this are seen in Facebook with "Like" being intentional and "Seen By" being unintentional (viz: doesn't require the user to do anything explicitly). My research project is to create a generic design pattern to easily define and include these into web pages.
Hopefully this gives some insight into the design, but I need to get 2 things working before I can start experiments and data collection.
My preferred solution:
Now I can build all of this using standard IFML and Data Units and Links, but ideally the implementation will be completely encapsulated in Custom Units. There is no variation in deployment, so I want the whole Custom Unit(s) to be black box. Just drop them on the page you want them, and specify the Sign Oid as the input parameter that the Unit builds itself (just add link to the current Selector (or Index) for run-time context). You can see this in the image attached where:
- Actuator Custom Unit (instantiates as Marker Based or Sematectonic) creates the "trail" and
- Sensor Custom Unit (instantiates as Quantitative or Qualitative) displays the trail.
NOTE : The Sensor can provide Quantitative output (number of "Likes" or "Seen By" or Qualitative output (similar to Facebook "Share" where it displays some linked content ... or Amazon "People who bought this also bought ...". Getting the Qualitative output is the second of the two things I need to get working and I will add detail to your response in this thread regarding the Sensor Unit.
Ok, so this question is only about the Actuator Custom Unit. It's a standard design Custom Unit with a service java class and a bean java class. It creates a record in the Contribution database table is two ways; one for Marker Based, one for Sematectonic.
The Sematectonic instantiation works because the unit calls the service bean upon page arrival, and fires of an INSERT method (viz: unintentional trail). No user interface is displayed, the bean returns this fact (via a boolean property) and the style unit has code to only create the interface if it's Marker Based. E.g.:
<c:if test="${<wr:UnitId/>.isMarkerBased}"> // build drop list (if needed) and button
.....
</c:if>
If the instantiation is Marker Based, then the style unit builds a User Interface. It can be either a single choice such as "Like" where only a single button is added to the style unit output. It can also offer a selection of options such as with eBay's "Rate It" feedback (viz: Satisfaction rating from 1 to 5), where the bean returns a map with an Oid/Description Map. As you can see on the image, the drop list is populated with the map contents (for the "Rate It" example) and a save button, or just a single button (for the "Like" example).
The Problem:
The button needs to respond to a user clicking it, and fire off an INSERT (somehow ... anyway at all) to store the intentional Contribution. The INSERT will need to include the value from the drop list that has been selected.
My best attempt was to create a button in the style sheet using:
<input title="<c:out value="${<wr:UnitId/>.signInputLabel}"/>" onclick="saveContribution(); return false;" class=" button" value="<c:out value="${<wr:UnitId/>.signName}"/>">
It is intended to fire some javascript (see saveContribution()) but I haven't been able to get it working. But you can see that the names of the buttons are dynamically created as per the description stored in the Sign database table.
I really would like to get this working, but can't find an example of how the button would be able to:
- fire off an INSERT into the Contrituion table
- link back to the page so that the Sensor Unit shows updated result for the new contribution.
I did ask a question here as to how to do this but alas no responses
I also hoped maybe the style unit could make a subsequent call back to the service class to notify that a link should be triggered programatically. Again, no response :(
Please note, ideally the button will fire code in the Custom Unit, or a Web Service! But this question I ask in this thread is my next attempt at a work around ... Getting either working will be excellent!
This Attempt:
My first attempt used a link to generate a button using default IFML. It creates the button, and can provide the code automatically to first the INSERT via a Create Data Unit, and solve the problem of re-entering the page to update the Sensor Unit display using an "OK Link". This is less than ideal because the code and INSERT never changes, and loses the black box simplicity if it could all be handled within the Custom Unit. However if the fact is it can't be done my preferred way, then adding Links is probably my only option but I need the link to be labelled as per the Sign data at runtime.
Reclarifying this question:
An IFML Link from the Actuator Custom Unit would auto-generate the button used to save users' intentional Contribution. But depending on what Sign Oid is passed in to the Custom Unit (to instantiate itself as), and what the "Input Label" description is for that sign's database record, how can I make the style unit re-label the Link Button to use the description from the custom unit bean ${<wr:UnitId/>.signInputLabel}
at run-time?
Any help greatly appreciated ... in fact if you even can make sense of the above and read this far then more Thank You! ;p