How to create reusable component in Struts 2 - struts2

Hi
I want to make reusable component in/for Struts 2 framework. For example, a login form having validations, authentication on form submission, error display, Forgot password link etc.
I want to create this form in such a way so that it can be placed anywhere within the site and in any site without any changes.
Please suggest what should I use or better if you can provide and reference for the example of such type of components.
Thanks
Krishan Babbar

Why not, this is Model View Controller, source code can be reused, for example if you want to go to another framework, everything you will need to modify is View, because each framework has its specific tags, you could do everything with simple html tags, but this is already a framework problem

Related

creating Entry form in Umbraco for Add/Edit/Delete/Search functions

This is repeatedly asked many times, however i couldn't find appropriate solution for my problem.
I want to create an Entry Form which will consists of following elements:
Text boxes, drop down fields (auto populated) , check boxes , radio buttons
After my research
i found that i need to create user control, or script file for above form and access it via Macro.
I don't want to use User control as my first preference is to controller-View-Model (i.e. cshtml)
I want to follow MVC approach to create above form. So
1) Do i need to create a seperate project for Add/Edit/Delete/Search Data Entry form?
2) OR i need to create cshtml file for the same(not so clear about this approach)
I'm looking this data entry form with easier for customization and i could use it in other applications as well.
From Umbraco 4.10 up to 6.0.x you can use MVC in Umbraco so there's no need to use an usercontrol. You probably want to use a SurfaceController where you can add any Action you want. The rest is standard MVC (Razor views to build your textboxes, drop downs, ...).
Check out the Umbraco MVC documentation where they explain how to use MVC in an Umbraco project.

.net mvc how to render data after table row click

I’m new to .net mvc and have become stuck when rendering data in my view.
I’m creating a small project management tool and I am currently working on the project admin section.
I’m sending a model that contains a list of all projects that a user has to a view that administers projects. The project list is rendered in a table. The model contains everything relating to the projects, phases, project users etc.
When I click on a row in the table, I would like to render the extended detail of that project below that table so it will display users and phases of the selected project.
With jquery I can do this, but I would like to code this event in the view using .net code and not use Jquery. My main objective is not to call back to the server as I have all the data available in the model.
I’ve searched around and can’t find that much detail about triggering events and rendering further detail on a page. I understand what partials do, but that would mean calling back to the server.
What is the best way to approach this type of problem? Should I just use JQuery? If I do use jquery, how do I then use html helpers in the script, if the script is not in the page?
You could have a form inside each row and a submit button to show the detail. When the submit button is clicked a controller action will be invoked and set the selected row project id which will use it to retrieve the project detail and passed back to the view. You will also need to retrieve the whole list of projects because in order to be able to redisplay the table as well. Your main view model will consist of a property representing the collection of all projects and another property containing the selected project details. Initially the details property will be null. When a project is selected you will assign it. Then inside the view you could test if the details property is assigned and render the details in a partial.
If you decide to use jQuery and AJAX then since you won't be redisplaying the entire page, you don't need to retrieve the project list for the view model in the details action. Only the details. And then simply refresh the corresponding section of the DOM with the partial returned by the action.

Grails- Add link href to button

I'm building a simple Grails app for a web development class. For the most part, the app is finished, but I'm having one sticking issue.
On the index page, I have a series of buttons that correspond to the List, Create, and other templates that are built in Grails via scaffolding. How can I dynamically pass on the correct path to the controller action?
In order to do this, I need to get the current page URL and add the proper location. Is that possible to do in Grails or should I stick with jquery or some other ajax solution?
What are you trying to achieve here,
If you want to generate link to controller actions that you can use for button href, you can do it like this,
<button href="${createLink(controller:'foo', action:'bar')}"/>
See the createLink tag
If you want to know controller and action name, ${controllerName} and ${actionName} can be used.
Can you use ${controllerName} to get the name of the current controller?
An alternative might be ${params.controller}, but again, not 100% sure it works in gsps

asp mvc file upload

I have a form in asp.net mvc 3 project with some properties (a name and some extra properties who need to be filled in).
What i also need is a file to upload in the same form.
I placed an input type "file" and that works when i use Request.File the file is ok.
But i'm also using form validation, so when my name is not filled in, it's not possible to save. That works fine, but then my file is cleared..
Someone who has a good example to use file upload in a form? (with other fields and validation)
In addition to #Neil Knight's excellent references in his answer, if you're using ajax (and you probably are or will be to leverage MVC's ability to facilitate partial page refreshes) the jquery plugin here has proved itself useful in enabling file upload without a full page navigation.

Adding html form and input tags into Symfony static pages

I inherited the management of a Symfony site and need to add some HTMl form tags to one of the "static" pages via the CMS. The scenario I have is:
/index.php/splash/welcome pulls up the welcome screen.
We want to be able to add a subscription button on that page.
The HTML has been supplied for us by the company that handles the subscriptions.
The form post method has an action that references a script on a remote site (no lectures on the security implications please ;-).
When I add the <form... and <input... tags via the CMS admin panel, the tags get removed automatically by Symfony.
Is there a way to tell Symfony to allow these tags?
Thanks in advance,
Marty.
This is goign to depend completely on how the developer set up the CMS. Youre using a rich text editor in source mode i would take a look at that editor's config file and documentation because its probably the one responsible for stripping the tags.
If its just a plain text area i would check the submit action for the edit form and take a look at the code... he may be using something to strip them in there.
If youre using one of the Symfony CMS plugins (Diem, Apostrophe, Sympal) i might be able to help further if i know which one youre using. If its something custom we would need to see the code. This isnt really indiciative of the Symfony core, but rather the CMS youre using.

Resources