What is the equivalent tag for bean:define in struts2.5? - struts2

<bean:define
id="beanObj"
name="<%=Constants.Header_details%>"
scope="session"
type="com.domain.HeaderDetails"
/>
The above tag is used in struts1 code. I am migrating to struts2.

Related

Struts 1 action tag input replacement in struts 2

I am trying to migrate the project from struts 1 to struts 2.5.16, so in the previous struts-configuration file there are many input tags that are used like as below:
<action name="Form" path="/activities"
type="-----" validate="true"
scope="request" input="/applications.jsp">
<forward name="ActivitiesView" contextRelative="true"
path="/abc.jsp" />
So what will be the replacement for input from above code chunk in structs2?
Take a look at following documentation.
https://www.infoq.com/articles/converting-struts-2-part1
https://www.infoq.com/articles/migrating-struts-2-part2
https://cwiki.apache.org/confluence/display/WW/Migration+Guide
Remember, migration from struts 1 to struts 2, requires a lot more than just replacing config file.

Struts 1.x to Struts 2.x Migration issues for Scriptlet in s:textarea field [duplicate]

This question already has an answer here:
According to TLD or attribute directive in tag file, attribute name does not accept any expressions
(1 answer)
Closed 5 years ago.
I am working on Struts 1.x to Struts 2.x migration and facing issues while assigning Scriptlet in textarea value.
The following code was written in Struts 1.x below :
<html:textarea name="shareFeedbackForm" style="height:50px;"
property="checkAllRemarks(${shrFeedbackHelperForm.groupId})" rows="1" cols="20"
value = '<%=(String)checkedMap.get(Long.parseLong((String)session.getAttribute("gId"))) %>' styleId="${shrFeedbackHelperForm.groupId}" onkeydown="limitRemarksText(this,500);" onkeyup="limitRemarksText(this,500);"></html:textarea>
I tried to re-write the same in Struts 2.x expression :
<s:textarea style="height:50px;"
name="webform.checkAllRemarks(%{#attr.shrFeedbackHelperForm.groupId})" rows="1" cols="20" value = '<%=(String)checkedMap.get(Long.parseLong((String)session.getAttribute("gId"))) %>' id="%{#attr.shrFeedbackHelperForm.groupId}" onkeydown="limitRemarksText(this,500);" onkeyup="limitRemarksText(this,500);"></s:textarea>
But, I am getting error in page where attribute value does not allow expressions. What is the correct way to assign the scriptlet in JSP page for Struts 2.x framework?
You Can Add Scriptlet in STRUTS 2 as follows
<%
String str=request.getAttribute("tDate").toString();
%>
<s:textfield value=<%=str %> name="toDate" id="toDate" />
Please try the following code
<s:textarea style="height:50px;"
name="webform.checkAllRemarks(%{#attr.shrFeedbackHelperForm.groupId})"
rows="1" cols="20" value = '<%=checkedMap.get(Long.parseLong(session.getAttribute("gId"))).toString() %>' id="%{#attr.shrFeedbackHelperForm.groupId}"
onkeydown="limitRemarksText(this,500);" onkeyup="limitRemarksText(this,500);"></s:textarea>

what is the difference between grails link ,createlink and resource tags

Is there any difference between grails link ,create link and resource tags and I want to know when to use each tag as per my knowledge the createlink tag has depricated
it's simple:
g.createLink generates only the url, like /aaa/bbb/222, based on controller/action/params for example
g.link generated the <a>-HTML-tag, using the g.createLink to generate the url to be put into the #href attribute
g.resource outputs a path to a resource file, available under web-app folder
<link rel="stylesheet" href="${resource(dir:'css',file:'style.css')}" />
produces
<link rel="stylesheet" href="/css/style.css" />
CREATE LINK is soemthing power full when u come to knowing the absolute or relative path in using likes inside a gsp page.
Let assume i have the following path /yourapp/controller1/view1
Instead of using
<a href="{grailscontext.thensomebaseurlstuff}/"+controller/view /> ,
which fails according to some context using the below will make it easy.
my link
<g:createLink url="[action:'list',controller:'book']" />
And ,glink is the above implementation using taglib form.. does the same effect as above but being in taglib makes reduce some computation or create some am not sure.
g.link("text of the link here", action:"foo", controller:"bar")
ResourceTags is no wonder its something help full and important in attaching either an image,css and js folder/file resource into a grails application.
// generates "/shop/css/main.css"
<g:resource dir="css" file="main.css" />
// generates "http://portal.mygreatsite.com/css/main.css"
<g:resource dir="css" file="main.css" absolute="true" />
// generates "http://admin.mygreatsite.com/css/main.css"
<g:resource dir="css" file="main.css" base="http://admin.mygreatsite.com"/>
Alloha!

Struts2 MessageResources in Apache Tiles

I'm trying unsuccessfully to use a Struts2 message resource in a tiles
2.1.4 expression. For example the following resource is available in
the JSP...
<s:text name="htmlheadHeading1"/><br/>
... but when I attempt to use the same resource in the tiles definition...
<put-attribute name="title" expression="${htmlheadHeading1}" />
... I get the error...
ELResolver cannot handle a null base Object with identifier 'htmlheadHeading1'
... Is there any way to do this??
This solution does not use tiles expressions but will work if you need to display localized text in JSP when key is passed through tiles definitions.
In tiles definition:
<put-attribute name="title" value="htmlheadHeading1" />
In your JSP then use Struts2 <s:set> tag to set title from tiles definition to local variable and then use it in <s:text> tag.
<s:set var="title">
<tiles:getAsString name="title" ignore="true"/>
</s:set>
<s:text name="%{#title}"/>

Something to dynamically Generate a UI to edit XML file?

I have an XML file with a lot of nodes similar to the following format:
<Factsheet page="GenericOfflineFactsheet.aspx" pageTitle="MyTitle" >
<TopStrapline text="BlahBlahBlah" />
<Commentary page="Text.ascx" />
<ChartPanel page="Bar.ascx" appearanceFile="Bar.xml" />
<Strapline text="blah blah blah" />
<Funds>
<fund id="215" countryid="N0" />
<fund id="561" countryid="N0" />
</Funds>
<LegalText effectiveDate="08 June 2010">
<Line id="30321" />
<Line id="10301" />
</LegalText>
</Factsheet>
Is there any free plugins (or any other means) out there that I could use in an ASP.NET MVC application to generate a basic UI for editing this kind of file?
What about LinqToXML? Then you can use this as your model in your controllers and views just like LinqToSQL.
LinqToXML

Resources