| Author |
bean:message key="" problem
|
Raghava Chary
Greenhorn
Joined: May 06, 2011
Posts: 6
|
|
How to find out,In <bean:message key=" "/> ,Key is present or not
....
My problem is,
if message is present, i have to display that one
other wise default one
can any body suggest me
|
 |
Bharat Kasodariya
Ranch Hand
Joined: Aug 19, 2011
Posts: 36
|
|
<logic:present name="message">
<bean:write name="message" />
</logic:present>
|
 |
Sandy Chatterjee
Ranch Hand
Joined: Jun 27, 2012
Posts: 55
|
|
<logic:present name="message">
<bean:write name="message" />
</logic:present>
@Bharat Kasodariya
Could you please explain what exactly the above code prints.
|
Take up one idea. Make that one idea your life; dream of it; think of it; live on that idea. Let the brain, the body, muscles, nerves, every part of your body be full of that idea, and just leave every other idea alone. This is the way to success.
|
 |
Sandy Chatterjee
Ranch Hand
Joined: Jun 27, 2012
Posts: 55
|
|
|
.
|
 |
Vidya Gupta
Ranch Hand
Joined: Mar 18, 2012
Posts: 96
|
|
The logic:present tag checks whether it contains any message or not.. And then if it contains the message then the bean:write will display the message..
|
 |
Sandy Chatterjee
Ranch Hand
Joined: Jun 27, 2012
Posts: 55
|
|
<logic:present name="message">
<bean:write name="message" />
</logic:present>
@Vidya
As per my knowledge the 'name' attribute of the <logic:present> tag is the name of any bean in a particular scope.
So, according to the code 'message' is a bean which is stored in some scope.
Is the 'message' bean the message resource bundle bean.
If so then how can we check a particular message is present or not.
Please explain.
|
 |
Sandy Chatterjee
Ranch Hand
Joined: Jun 27, 2012
Posts: 55
|
|
|
Still waiting for reply from Bharat Kasodariya and Vidya Gupta
|
 |
Vidya Gupta
Ranch Hand
Joined: Mar 18, 2012
Posts: 96
|
|
Sorry i was little bit busy and unable to visit the site..
As per my knowledge, here in logic:present tag the attribute "name" defines a scripting variable to be used as the variable being tested for existence.
Here we are testing that particular variable is present in the scope or not...? And then if it is present in a scope it will enter into the body of the tag and then bean:write attribute displays the values of the properties in the form.
|
 |
Shankar Tanikella
Ranch Hand
Joined: Jan 30, 2011
Posts: 329
|
|
Hi Sandy,
Have you looked into this messagesPresent tag provided by struts? I feel this is what you are looking for. Google for couple of examples as well.
|
Have Fun with Java
little,little.. little by little makes a lot..
|
 |
Raghava Chary
Greenhorn
Joined: May 06, 2011
Posts: 6
|
|
|
it is not working
|
 |
Shankar Tanikella
Ranch Hand
Joined: Jan 30, 2011
Posts: 329
|
|
Hi Chary,
Did you set the "message" attribute to true?
What have you tried?
|
 |
Sandy Chatterjee
Ranch Hand
Joined: Jun 27, 2012
Posts: 55
|
|
Thanks Shankar and Vidya for your reply.
I knew about <logic:messages> tag. But the thing which was bothering me was the post by Bharat Kasodariya
He has used something called message. That was really a new thing for me to learn.
Also Vidya wanted to explain which was not exactly clear to me.
I just wanted to know about the above code.
@Vidya
As per my knowledge, here in logic:present tag the attribute "name" defines a scripting variable to be used as the variable being tested for existence.
Here we are testing that particular variable is present in the scope or not...? And then if it is present in a scope it will enter into the body of the tag and then bean:write attribute displays the values of the properties in the form.
I understood what you want to mean but what Raghava Chary asked was that he wanted to check a value is present or not from the message ResourceBundle. Where is the Message here. Is that 'anyname'?
|
 |
Shankar Tanikella
Ranch Hand
Joined: Jan 30, 2011
Posts: 329
|
|
As mentioned here, Logic present tag would not look for resource bundle. So the above two solutions should not work.
|
 |
Sandy Chatterjee
Ranch Hand
Joined: Jun 27, 2012
Posts: 55
|
|
Thanks for your reply. I knew it was wrong but I was confused when it was supported by a second user.
Anyways tell me one thing
In the above code is 'myproperties.configured.resources.key' a key in the Resource Bundle?
Because I don't think so.
It has to be initialized in the Action class' execute() method by the following way:
where 'error.name.required' is defined in Resource Bundle.
Correct me if I am wrong as the guy who has posted this question is being misguided by wrong answers.
Regards,
Sandy
|
 |
 |
|
|
subject: bean:message key="" problem
|
|
|