242014Sep

Creating Dynamic Success URL In FormHandler In ATG

Success URL In FormHandler in ATG

Success URL in ATG is the URL used in formhandlers when we want to redirect the user after successful submission of form whether it is creating, updating or deleting a row.

e.g

.
.
<dsp:input type="hidden" bean="TestFormHandler.createSuccessURL" value="succesurl.jsp" />
.
.

The above code will redirect the user to “succesurl.jsp” after successful submission of form i.e row is created in database.

But there are some cases in which we want to generate Dynamic URL based on input enter by the user like :-

  • based on user attributes we want to redirect to another page.
  • we want to pass the repository id in the success url.

For achieving this in ATG we have Hooks like postCreateItem, postUpdateItem and postDeleteItem. So in the above case if we want to pass the repository id after successful creation of new item we can use  postCreateItem.

protected void postCreateItem(.., ...)
{
	setSuccessURL(getSuccessURL()+"?newId="+getRepositoryId());
}

In this case after creating new row Success URL is modified and we have passed repository id in the Success URL.