Stage 3: Profile settings servlet setup
At this point open the project in your IDE.
Create a new class TwitterSettingServlet which will let you set Twitter credentials from the admin panel.
Http GET: Hello world
Let's start with very simple output. Override method
New entry in Profile settings
To make your servlet visible in the Profile settings menu, add it to
Install the servlet with
pi and go to http://localhost:3990/fecru/. Expand the top-rightmost menu and choose Profile settings. You should now see Twitter Configuration on the list. Click it to get your "Hello world!" message. Notice that the menu disappeared.
Decorate servlet with userprofile.tab decorator
Add the following lines at the beginning of the servlet's
Refresh the page and check that after clicking Twitter Configuration the menu on the left no longer disappears.
Menu item highlighting
The Twitter Configuration item is not highlighted correctly when selected. That's because the decorator can't identify the link belonging to the active tab. We need to set the
profile.tab.key attribute to the key of the Web Item. Replace the plain "Hello world!" string with:
com.example.ampstutorial.fecrutwitter:config-link is the plugin key (from the
<atlassian-plugin> element) and the key of the Web Item, separated by a colon.
Now the correct text should be highlighted when you click on the Twitter Configuration link.
Your servlet can use a templating library to produce HTML. FishEye/Crucible provide some utility classes to help you use Velocity , but you could use other libraries too.
Add TemplateRenderer dependency
Add TemplateRenderer component
Create basic template
In the resources directory create the "Hello world!" template:
Inject template renderer
doGet replace the response you had so far with: