Rename new created page

I try to rename a page created with a TemplateProvider directly when the user is in edit mode before it is saved, so it is directly saved with the programmed name. So I added to the class sheet.

#elseif($xcontext.action =='edit')
    #set($discard = $doc.rename('testname')

But it is not working. When the user saves the document, the name is not ‘testname’. Can you help me? Thanks a lot!

Rename won’t work since the page doesn’t exist until it’s saved. But there’s no need to rename anything since you decide the page location and name in the edit URL.

See for example or

Hope it helps

Is it possible to change the behavior of the save & view button ? So I could send this request with pressing the save&view button ?