Rename new created page

Hey,
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')
  #if($doc.isNew())
    #set($discard = $doc.rename('testname')
  #end 
#end

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 https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/FAQTutorial/FAQTutorialManual#HCustomcreationform for example or https://www.xwiki.org/xwiki/bin/view/FAQ/How%20can%20I%20create%20a%20new%20page%20based%20on%20a%20form

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 ?