Understanding the struts2 configuration file - struts

The below piece of code was written in struts-config file.but i am not able to understand it.
<action path="/showWelcome"
type="com.code.base.presentation.struts.actions.StrutsIoCAction"
name="LoanDetailPageLoadForm"
parameter="GET_WELCOME_PAGE"
input="welcomePage"
validate="false"
scope="request">
<set-property property="requestDTOKeyName" value="ItemDataRequest" />
<set-property property="responseDTOKeyName" value="ItemDataResponse" />
<set-property property="exceptionDTOKeyName" value="ProfileSekerException" />
<set-property property="businessServiceId" value="ItemsDataMgmtService" />
<forward name="success" path="welcomePage" />
<forward name="failure" path="sysError" />
</action>
My question is
what is the usage of path attribute?
what is the usage of parameter attribute?
what is the usage of input attribute?
what is the usage of <set-Property>?
Help me guys on this.
Note:
as per my understanding there should be "showWelcome.jsp" page in the application but it is not there.(then what is use of that?)

It specifies where the action is mounted. For example, this action would respond on http://yourservice.dom/showWelcome.
Parameter is the string you get by calling ActionMapping.getParameter(). Any string you want to pass to your action.
Input is a path where the user would be redirected if he fills the form incorrectly. As there's validate=false, I'd say that would never happen.
Obviously, it sets a property on com.code.base.presentation.struts.actions.StrutsIoCAction. I think it calls setter, i.e. it would call setRequestDTOKeyName(), setResponseDTOKeyName() etc.
But if you're going to use struts for a considerable time, QA won't get you far, read some docs on struts' config file.

Following on from #Alamar's response...
There is no showWelcome.jsp. "/showWelcome" is the URL, but that does not correspond to the name of any actual filename on the server. If this action's configuration contained a line like this:
<forward name="success" path="showWelcome.jsp" />
Then it would mean that if the action class (StrutsIoCAction) returns success, a file called showWelcome.jsp would be executed. However, as you can see, the actual configuration is a forward to "welcomePage", which is probably not a file but instead the name of another action (also defined in struts-config).
Note: "forward" just means that execution is passed to this other action, it does not mean that the user is redirected to another URL.

Related

Azure B2C You are already registered, please press the back button and sign in instead

I have created a custom B2C_1A_SIGNUP_SIGNIN Policy.
Used Google Authentication.
When I hit the create button mypersonaltenantid gets validated through a Azure Function.
I am presented the error message You already registered, please press back button and sign in instead.
Before executing this policy i made sure this user does not exist-
After the error message is displayed i look inside B2C: The user was created incl. my custom claim with value mypersonaltenantid.
I was assuming that i am transferred to a different page after signup. Is this assumption wrong?
Created a Issue and got the final hint.
Looks like a action was performed twice. In my case I had a Base policy and a extension policy which had a ValidationTechnicalProfiles section.
Base.xml
<ValidationTechnicalProfiles>
<ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingAlternativeSecurityId" />
</ValidationTechnicalProfiles>
Extension.xml
<ValidationTechnicalProfiles>
<ValidationTechnicalProfile ReferenceId="REST-ValidateTenantId" />
<ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingAlternativeSecurityId" />
</ValidationTechnicalProfiles>
My assumption after both files get merged:
<ValidationTechnicalProfiles>
<ValidationTechnicalProfile ReferenceId="REST-ValidateTenantId" />
<ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingAlternativeSecurityId" />
</ValidationTechnicalProfiles>
But it looks like the merge is performed like this:
<ValidationTechnicalProfiles>
<ValidationTechnicalProfile ReferenceId="REST-ValidateTenantId" />
<ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingAlternativeSecurityId" />
<ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingAlternativeSecurityId" />
</ValidationTechnicalProfiles>
Of course that explains why AAD write is performed twice.
From my point of view the error message is quite misleading.

Dynamically import of options in camel routes

I am trying to find a way to pass in "destAddr=" in smpp route below, a value that comes from the above sql query in order to import the senders number in the sms destination address but after much search, I can't find a way. How can I save the value I need from the query and then use it dynamically in the smpp option? Any suggestions would be much appreciated.
<from uri="sql:{{sql.selectRunRecList}}" />
<to uri="bean:smppBean?method=smsConstruct" />
<to uri="sql:{{sql.markSms}}"/>
<to uri="bean:smppBean?method=smsPrintText" />
<to uri="file:C:/workspace/SMPP/outbox" />
<to uri="smpp://smppclient#localhost:2775?password=password&destAddr= " />
See this FAQ how to use dynamic values when sending to an endpoint in Camel
http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html

How to use a property that was set in a custom action?

I want to set a property in a custom action and use it in the standard custom action "util:User" afterwards. But no matter where I put the property in my wxs-file, I always get "error LGHT0094 : Unresolved reference to symbol"
Details:
In my setup I want to add a new user by using util:User. The user should be added to the group "Power Users" by using util:GroupRef. No Problem so far. Unfortunately the group names are language dependent. In german "Power Users" is "Hauptbenutzer". So I want to look up the well known SID S-1-5-32-547 in a custom action, set a property in this custom action by calling MsiSetProperty and then use the property for util:GroupRef.
As far as I understand, the property must be declared somewhere in the wxs-file.
In the examples I found, the property was never declared as follows (but I also tried that):
<Property Id="TextSID" Value="Power Users" />
In the examples there always was a custom action to set the property, like:
<CustomAction Id="SetTextSID"
Property="TextSID"
Value="Power Users"
Return="check" />
My problem is, that the creation of the user fails to "compile" because the property "TextSID" is not known:
<Component Id="CreateUser" Guid="Some GUID here in my original wxs file">
<util:User Id="UserUser"
Name="User" Password="Password"
CanNotChangePassword="yes" PasswordNeverExpires="yes">
<util:GroupRef Id="TextSID" />
</util:User>
</Component>
I have never done a custom action before and I'm a new to WiX and MSI, so any idea would be very welcome.
Regards
Ralf
Sorry for wasting your time.
I stared at my XML for hours before I posted this question, just to find the answer immediately after my post :-(
My only problem was, that it is not possible to reference to something that isn't there. In this case the "util:Group" was missing.

Problem with struts 2 and json plugin

I'm using the json plugin that comes with struts 2 (json-lib-2.1.jar) and trying to follow the website to set it up.
Here's my struts.xml
<struts>
<package name="example" extends="json-default">
<action name="AjaxRetrieveUser" class="actions.view.RetrieveUser">
<result type="json"/>
</action>
</package>
</struts>
but I get this warning:
SEVERE: Unable to find parent packages json-default
Is there something else I'm supposed to do?
Edit:
I added this method to my RetrieveUser:
public Map<String,Object> getJsonModel()
{
return jsonModel;
}
And my struts.xml looks like this:
<struts>
<package name="example" extends="json-default">
<action name="AjaxRetrieveUser" class="actions.view.RetrieveUser">
<result type="json"/>
<param name="root">jsonModel</param>
</action>
</package>
</struts>
However, I don't think the response is going from the RetrieveUser class to the javascript. I'm using firebug and no request gets sent.
I believe that net.sf.json-lib is just a toolset you can use in your Java to build up JSON-ready objects, suitable to be returned by actions such as you describe.
Probably, you need to include struts-json-plugin - make sure its version matches your struts version.
I notice also that as written, your action will attempt to return RetrieveUser, serialized. Most implementations I've done/seen specify the root object to be returned, by adding
<param name="root">jsonUser</param>
Under the tag, and define this method in RetrieveUser
public Map<String, Object> getJsonUser()
[This is mentioned in the Sruts2 doc]. Hope that helps.
[edit] I use Map - you could also use the object structures provided by json-lib instead.
Re: Your edit. Probably need to see your calling javascript. And probably I will suggest that you make sure you have both a success and an error handler. Can you debug/log to show that the method is being called in java ? Do your logs show anything ? This is usually some sort of error....

Forwarding in STRUTS

I am forwarding to an action by giving as
<forward name="sample" path="/sample.do?button=default" />
i want to add one more attribute in path and i used:
<forward name="sample" path="/sample.do?button=default&value=text" />
...and I am getting org.xml.sax.SAXParseException
Any solution for it?
As Omnipresent and Shashi already said, you must encode the ampersand as & so that the forward definition looks like this:
<forward name="sample" path="/sample.do?button=default&value=text" />
However, the URLs defined in your struts-config.xml are frozen, and if you need to dynamically change a value or add another parameter, you can do it by creating a new ActionForward based on the forward that you get from mapping.findForward().
ActionForward forward = mapping.findForward("sample");
StringBuilder path = new StringBuilder(forward.getPath());
path.append("?id=");
path.append(someobject.getId());
path.append("&value=");
path.append(getValue());
return new ActionForward(path.toString());
<forward name="sample" path="/sample.do?button=default&value=text" />
You can pass multiple parameter in forward.
But you have to use '&' instead of '&'.
To be strictly accurate, the parser handler should scan the buffer for ampersand characters (&);and left-angle bracket characters (<) and replace them with the strings & or <, as appropriate.
So, the forward statement will be as
<forward name="sample" path="/sample.do?button=default&amp;value=text" />
you can not use '&' in struts-config.xml
value=text should be passed from your action...not the way you are trying to pass it (in url).
Your forward tag must be associated with an action. that action should have a getter called value which returns 'text'.
what way sample.do will have access to that varable.