Could the missing ) be your problem

<a href="#" onclick="select('${value}'">${value}</a>

Also I'd recommend using href="" onclick="whatever(); return false;" .. I can't 
recall the reasons but we did switch from # to that.

Other than that, I guess it's Friday, but I'm having a hard time understanding 
your problem.

"a requirement for my components to feed data back to the page which is using 
them"

You're saying these 2 lines need updated?

    <s:hidden name="selectedValue"/>
    Current Value: ${actionBean.selectedValue}


function update()  {
  new Ajax.Updater('updateContainer', <url>, <params w/ _eventName>);
}

<div id="updateContainer">
     <jsp:include "those2Lines.jsp">
</div>

those2Lines.jsp:

<stripes:form partial=true beanclass=${actionBean.currentBeanClass}>
       <s:hidden name="selectedValue"/>
    Current Value: ${actionBean.selectedValue}
</stripes:form>

Again, I don't fully grasp what you're asking, so that may be nothing new to 
you.

From: Dan Mace [mailto:[email protected]]
Sent: Friday, December 18, 2009 2:55 PM
To: Stripes Mailing List
Subject: [Stripes-users] Reusable AJAX components using JSP fragments and 
partial Stripes forms

I've been reading through the mailing list archives and have done a ton of 
experimentation, but still can't quite wrap my mind around the solution to 
this. Here is a use case. I don't have any code here in front of me to paste, 
so I'll do my best to describe it in prose. If I don't do a good enough job, 
I'll see if I can dig up some example code when I get home tonight...

Scenario: Many forms within the application allow the user to select a certain 
value from a pop-up hierarchical browser component, which, when selected, needs 
to eventually get bound back into a property of the ActionBean. The "partial" 
form gets data from a different ActionBean than the thing which includes it. 
Here's the general setup for a simple form which includes this component via a 
<jsp:include>. For the sake of simplicity, I'm omitting tons of stuff like 
wrapping the component in a popup, demonstrating the functionality of the 
hierarchy browser, etc:

<s:form actionBeanClass="some.RandomAction">

Field: <s:text name="someField"/>

Another Field: <s:text name="anotherField"/>

Browsable Field:
    <s:hidden name="selectedValue"/>
    Current Value: ${actionBean.selectedValue}
    Browse for New Value:
    <jsp:include page="valueSelector.jsp"/>

</s:form>

And here's the "component" jsp (valueSelector.jsp):

<s:useActionBean beanclass="some.BrowserAction"/>

<div id="valueBrowser">

<div id="valueBrowserValues">
<ul>
<c:forEach items="${actionBean.values}" var="value">
   <li><a href="#" onclick="select('${value}'">${value}</a></li>
</c:forEach>
</li>
</div>

<a href="#" onclick="next()">Next</a>

</div>

So, I hope I have demonstrated the basic ideas I'm interested with this:

1. When the initial page renders for RandomAction,

  a. The "selectedValue" property is displayed, and bound via the 
"selectedValue" hidden field.

  b. The browser component is rendered, and gets its initial state from the 
"values" property of a DIFFERENT ActionBean, "BrowserAction".

2. After initial page render,

  a. The user clicks the "Next" link in the browser, which makes an AJAX call 
to BrowserAction's "next" event, which fills the "values" property with the 
next list of items, and replaces the contents of "valueBrowserValues" with a 
freshly rendered view of "valueSelector.jsp" (the JS for this is not displayed 
in the example). This works perfectly well.

  b. The user clicks on a value, which fires the "select" JavaScript function, 
which somehow needs to make its way back to the "selectedValue" hidden field 
(and preferably to update the current display value, if it were to be wrapped 
in a span or something. This is where my problems lie.

I have no idea how to accomplish this without coupling the component to the 
invoking page so that the "select" function can act upon its container's 
elements.

Another thought I had was to make the "component" encapsulate the actual 
selected value control as well, so that the partial now looks like this:

<s:useActionBean beanclass="some.BrowserAction"/>

<div id="valueBrowser">

<s:hidden name="selectedValue"/>

<div id="valueBrowserValues">
<ul>
<c:forEach items="${actionBean.values}" var="value">
   <li><a href="#" onclick="select('${value}'">${value}</a></li>
</c:forEach>
</li>
</div>

<a href="#" onclick="next()">Next</a>

</div>

In this case, the select() function would update the hidden field it "knows" 
about... however, selectedValue needs to be bound to the CONTAINING ActionBean, 
not the component's ActionBean.

Is this making any sense? AJAX partials with Stripes have been working great 
for me up until this point where it became a requirement for my components to 
feed data back to the page which is using them. I am starting to wonder if I'm 
just going about it the wrong way entirely due to a misunderstanding of one of 
the concepts in use...

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to