I thinking about this solution. Unfortunately I must add this option to
all ajax form loop rows both of which are persist in DB and new added
rows witch arent persist anywhere yet. It should be option which always
take current row and paste it below copying all data from current row,
regardless of whether data persist or no. And after all I should persist
all new added row using ajax form loop mechanism.
W dniu 2013-04-12 18:24, George Christman napisał(a):
Providing the data has been saved to the database and an id exist,
couldn't you use something like
<t:ActionLink t:="yourId" context="person.id"
t:zone="someZone">Button</t:ActionLink> next to your remove action.
Then in the backend create an event handler for your action,
Object onActionFromYourId(Person person) {
//do something
return someZone.getBody();
}
Lastly, process zone in the interface.
Not sure if that helps.
On Thu, Apr 11, 2013 at 3:07 PM, Lenny Primak
<lpri...@hope.nyc.ny.us> wrote:
Basically, you are using Ajax to trigger an action. AjaxFormLoop
expects certain things (context)
to be in the Tapestry environment (see @Environmental) and it isn't.
This is why you get the exception.
I haven't used AjaxFormLoop myself, and don't know how to help you
further,
but perhaps somebody can help here.
Now your question is worded so someone can answer it I think...
On Apr 11, 2013, at 1:41 AM, Bartlomiej Kalata wrote:
I put some example code to show what I try to do and discribe my
problem. I show this based on modify jumpstart ajaxformloop example
http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/formloop1:
Example.tml
<table>
<tbody t:type="AjaxFormLoop" t:source="persons" t:value="person"
t:encoder="personEncoder">
<t:submitnotifier>
<t:delegate to="block:apFormFragmentBlock"/>
<t:block id="apFormFragmentBlock">
<tr>
<td><input t:type="TextField" t:id="firstName"
t:value="person.firstName"/></td>
<td><input t:type="TextField" t:id="lastName"
t:value="person.lastName"/></td>
<td><input t:type="Select" t:id="region"
value="person.region"/></td>
<td>
<t:removerowlink>remove</t:removerowlink>
</td>
<td>
<div id="copyCurrentRow">copy current row</div>
</td>
</tr>
<tr>
<td>
<div t:type="FormInjector" t:id="injector" id="injector"/>
</td>
</tr>
</t:block>
</t:submitnotifier>
<p:addRow>
<tr>
<td colspan="6" style="text-align: right">
<t:addrowlink>Add a row</t:addrowlink>
</td>
</tr>
</p:addRow>
</tbody>
</table>
Example.java
@Getter
private Person person;
@Inject
private Block apFormFragmentBlock;
@OnEvent(EventConstants.ACTION)
public Block onAction(){
// In real code this should be copy of existion element
this.person = new Person();
return apFormFragmentBlock;
}
example.js
$("#copyCurrentRow").bind('click', function() {
$("#injector").tapestryFormInjector("trigger");
});
My problems:
1) Insisde ajax form loop id od injector element changes, but I
propably find solution in jquery how to find this element
2) When I click on copy I have exception and I don't know how to do
this in ajax form loop context :
Caused by:
org.apache.tapestry5.ioc.internal.util.TapestryException: No object
of type org.apache.tapestry5.corelib.internal.AjaxFormLoopContext is
available from the Environment. [at
classpath:pl/raiffeisen/aml/gs/presentation/components/tabs/ApData.tml,
line 94]
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:153)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$BeginRenderPhase.render(ComponentPageElementImpl.java:209)
at
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
... 146 more
Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: No
object of type
org.apache.tapestry5.corelib.internal.AjaxFormLoopContext is
available from the Environment.
at
org.apache.tapestry5.internal.services.EnvironmentImpl.peekRequired(EnvironmentImpl.java:88)
at $Environment_128a351287b.peekRequired(Unknown Source)
at $Environment_128a351277a.peekRequired(Unknown Source)
at
org.apache.tapestry5.internal.transform.EnvironmentalWorker$EnvironmentalConduit.get(EnvironmentalWorker.java:59)
at
org.apache.tapestry5.corelib.components.RemoveRowLink.conduit_get_context(RemoveRowLink.java)
at
org.apache.tapestry5.corelib.components.RemoveRowLink.beginRender(RemoveRowLink.java:56)
at
org.apache.tapestry5.corelib.components.RemoveRowLink.beginRender(RemoveRowLink.java)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$BeginRenderPhase.invokeComponent(ComponentPageElementImpl.java:202)
at
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:133)
... 148 more
W dniu 2013-04-10 19:41, b...@softwaremind.pl pisze:
Ok, I try to explain my problem clearly.
I implemented dynamic generation of form inputs using ajax form
loop. I used Tapestry core remove and add row components to remove
and add new input fields form fragment. It works perfectly. But my
client want to make button on each ajax form loop row (similar to
standard remove button) which should copy existing (read from DB) or
newly completed row and paste it below current element. I try to
used form fragment or add add row component to implement this task
but it doesn't work. I do not quite know how to approach this
problem. Perhaps you could give me some simple example how to do
this or give a link to ready solution. Maybe someone has already
solved similar problem or write copy existing row component. I can
attach some source code but is it a lot and complicated.
W dniu 2013-04-10 18:50, Lenny Primak napisał(a):
This question isn't nearly detailed enough or worded in a way
that is
possible to answer.
On Apr 10, 2013, at 9:56 AM, Bartlomiej Kalata wrote:
Hi,
I have problem to implement some funtionality using Tapestry
5.6.3
I'm using ajaxformloop to add new row and remove exisiting, but
I must write duplicate option for each row, which copy current row
and inject it below exisiting element with data from existing row.
Can you tell me what is the best way to do this task?
--
Bartłomiej Kalata
Software Engineer II
Software Mind SA | Focused on Results
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
--
Bartłomiej Kalata
Software Engineer II
Software Mind SA | Focused on Results
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org