tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Namron <normanm...@btinternet.com>
Subject No object of FormSupport available / ajaxformloop
Date Tue, 01 Mar 2011 18:11:05 GMT
I have taken the sample/tutorial application and have extended it with an
ajaxformloop (see main.tml below). Also see Main.java snippet below. I am
very new to tapestry and I am happy to admit this is a "bodge" to get
something working or a "quick win" based on a couple of ajaxformloop
examples I found on the internet.

However this application works on Eclipse/Jetty. However I has to deploy it
to OC4J using JDeveloper. I think I have every thing included I need in the
OC4J version. I didn change the context-root to something else. That works
ok (or seems to). The first page of the application renders and functions
ok, however the second page (Main) doesn't. It displays ok, the submit also
works. However Clicking "Add Row" results in an AJAX type error (see below)

I am confused to how the Form seems to work, but the ajaxformloop aspects
don't. It might be something to do with the lifecycle getting confused? Any
help REALLY REALLY appreciated.


ERROR

Ajax failure: Status 500 for
/getxml/main.phones.rowinjector:inject?t:formcomponentid=Main:worksrefedit&t:formid=worksrefedit:
Render queue error in
org.apache.tapestry5.internal.structure.RenderPhaseEventHandler$1@1930c18:
No object of type org.apache.tapestry5.services.FormSupport is available
from the Environment. Available types are
org.apache.tapestry5.RenderSupport,
org.apache.tapestry5.ValidationDecorator,
org.apache.tapestry5.corelib.internal.AjaxFormLoopContext,
org.apache.tapestry5.internal.services.DocumentLinker,
org.apache.tapestry5.services.ClientBehaviorSupport,
org.apache.tapestry5.services.Heartbeat,
org.apache.tapestry5.services.javascript.JavaScriptSupport.
Communication with the server failed: Render queue error in
org.apache.tapestry5.internal.structure.RenderPhaseEventHandler$1@1930c18:
No object of type org.apache.tapestry5.services.FormSupport is available
from the Environment. Available types are
org.apache.tapestry5.RenderSupport,
org.apache.tapestry5.ValidationDecorator,
org.apache.tapestry5.corelib.internal.AjaxFormLoopContext,
org.apache.tapestry5.internal.services.DocumentLinker,
org.apache.tapestry5.services.ClientBehaviorSupport,
org.apache.tapestry5.services.Heartbeat,
org.apache.tapestry5.services.javascript.JavaScrip




MAIN.TML
<html t:type="layout" title="Get XML"
  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
  xmlns:p="tapestry:parameter">


<form t:type="form" t:id="worksrefedit">
   <div t:type="ajaxformloop" t:id="phones" source="workRefs" 
value="workReference" encoder="encoder">
         
          <t:textfield t:id="WorksReference"
value="workReference.workReference" t:validate="required,minlength=3"
size="30"/>

          |

          <t:removerowlink>remove</t:removerowlink>


        
       
        
  
  </div>
   <input type="submit" value="Get ZIP File"/>
  </form>
  
|


</html>

Main.java

public class Main {
	
	@Property
	@Persist
	private List<WorkReference> workRefs ;
   

	@Property
	  private WorkReference workReference;

	@Inject
	private ComponentResources _resources;
        
        @Component(id = "worksrefedit")
        private Form form;

	
      

	void onActivate() {
		
	}

	

	void onPrepare()
	{
              
                if(form.isValid())
                {
		System.out.println("on prepare");
              
		if(workRefs == null)
		{
		workRefs = new ArrayList<WorkReference>();
                WorkReference initialReference = new WorkReference();
                initialReference.setWorkReference("");
                workRefs.add(initialReference);
		}
                }
              
		
	}

	public Object onSuccess()
	  {	
		workRefs = new ArrayList<WorkReference>();
		_resources.discardPersistentFieldChanges();
	    return null;
	  }

	 
          Object onAddRowFromPhones()
	  {
            System.out.println("Add row from ");
	    WorkReference workRef = new WorkReference();
	    workRef.setWorkReference("");

	    
	    workRefs.add(workRef);
	    

	    return workRef;
	  }

	 
	  void onRemoveRowFromPhones(WorkReference work)
	  {
	    workRefs.remove(work);
	  }


	
	

	.....

	@SuppressWarnings("unchecked")
	public ValueEncoder getEncoder() {
		return new ValueEncoder<WorkReference>() {

			public String toClient(WorkReference value) {
				return value.getWorkReference();
			}

			public WorkReference toValue(String keyAsString) {
				
				for (WorkReference holder : workRefs) {
					System.out.println(holder.getWorkReference());
					if (holder.getWorkReference().equals(keyAsString)) {
						return holder;
					}
				}
				throw new IllegalArgumentException("Received key \"" + keyAsString
						+ "\" which has no counterpart in this collection: " + workRefs);
			}
		};
	}




-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/No-object-of-FormSupport-available-ajaxformloop-tp3405447p3405447.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Mime
View raw message