s:select problem with data conversion

2008-12-24 Thread Oleg T.
Hi, I am using Struts 2.0.12 and having a problem getting selected=""
to work on s:select with my data converter. It seems that converter is
called when I submit from the select box, but when its populated its
never called.

1. My select is:



2. Converter is defined in xwork-conversion file

3. public class StateConverter extends StrutsTypeConverter {

public Object convertFromString(Map context, String[] values,
Class toClass) {
StateDAO stateDAO = new StateDAOHibernate();
return stateDAO.findById(Integer.parseInt(values[0]), false);
}

public String convertToString(Map context, Object o) {
State state = (State) o;
return String.valueOf(state.getId());
}
}


So on view the select list is populated from states which is
List but even though my State state; is set, its not being
selected. However, if I add  I do get Id of
that State so conversion is working but it seems as if its ignored by


How does setActionErrors Method works?

2008-12-24 Thread taj uddin
Hi,

In my application I have passed the list of errors to the setActionErrors( ) 
method and in the resulting jsp page i have written the tag 
I have a doubt like will this tag get the list, which was passed to the 
setActionErrors( ) method, and display the errors?
Pls help me out in this issue.



  

RE: Bean Properties are lost

2008-12-24 Thread dusty

If you do not need to edit the collections as part of the "post" transaction
then you can use the ParamsPrepareParams interceptor pattern.  Basically,
this lets you edit part of a model object without having to recreate the
whole thing in your form.  The basic pattern is to put the id in a hidden
field and then to implement Preparable in your Action.  You use the
prepare() or the prepareXXX() to pre-populate your action's model from the
database, including collections and other relationships that are hard to
duplicate in the form.  Then when Struts2 applys the parameters from your
post it will only update the fields you submitted and leave the original
values in place for when you save.

If you want to edit the list, that is a different if not as frequent
pattern.  In this case, you want to be able to add/remove relationships to
your model without having to save the model each time.  You want all of your
changes to post when the user clicks Save.  This allows the user to click
Cancel or leave the page (even accidentally) without getting your models in
a weird state.

To do this you need to create the text fields that represent the bean's
properties.  The fields don't have to be hidden, but hopefully they are just
scalar values and not additional relationships or else things get
complicated, but not impossible.  You need to name your fields with a
convention similar to model.collection[%{row.index}].propertyname, where row
is the status of your iterator.  You can use index or count, index is 0
based and count is 1 based.  If this bean in the collection has already been
persisted then you want to include its ID as well.  Finally, you need to
make an entry in your -conversion.properties file for the action that tells
Struts2 what kind of beans are in your collection so it knows what to
create.  You can look that up under Type Conversion docs.

These are all for where your model has a one to many relationships.  When
there is a one-to-one or many-to-one in your interface, and the end result
is selecting a single bean for the relationship, you can use Type
Conversion.  The string representation of your bean is its id and then you
can use that in the type converter to look it up from the database and put
the actual full bean in the model's property.



dusty wrote:
> 
> This is a fairly common issue.  I don't have time right now but if no one
> shows you I can show you tonight.  It is a combination of type conversion
> and the prepare filter depending on your requirements.  If you want to try
> to figure it out on your own in the meantime, look at the type conversion
> docs for collections.
> 
> Richa Pandharikar-2 wrote:
>> 
>> Dave,
>> 
>> No inputs ???
>> 
>> 
>> 
>> -Original Message-
>> From: Biesbrock, Kevin [mailto:biesbrock.ke...@aoins.com] 
>> Sent: Monday, December 22, 2008 12:23 PM
>> To: Struts Users Mailing List
>> Subject: RE: Bean Properties are lost
>> 
>> I would guess, then, maybe chaining the actions or storing the
>> collections in a session variable.  Another idea would be to make the
>> collection a character delimited string and store that in a hidden
>> input.  Don't know what the best way is, though.
>> 
>> I'm interested to know the most efficient way as well. 
>> 
>> 
>> Beez
>> ( 4961 
>> 
>> -Original Message-
>> From: Richa Pandharikar [mailto:richa.pandhari...@tdktech.com] 
>> Sent: Monday, December 22, 2008 12:21 PM
>> To: 'Struts Users Mailing List'
>> Subject: RE: Bean Properties are lost
>> 
>> I had tried to set the collection as a hidden property, but then I was
>> getting "invalid value" error when I submit the form. 
>> 
>> Please not I do not have any validation rules configured for the hidden
>> properties.
>> 
>> - Richa
>> 
>> -Original Message-
>> From: Biesbrock, Kevin [mailto:biesbrock.ke...@aoins.com]
>> Sent: Monday, December 22, 2008 7:34 AM
>> To: Struts Users Mailing List
>> Cc: Richa Pandharikar
>> Subject: RE: Bean Properties are lost
>> 
>>  
>> Make sure you're putting everything in your jsp.  If the field doesn't
>> need to be displayed, use the  tag.
>> 
>> The problem is with your internal mail server.  Your company's spam
>> filter is viewing your email as spam; whether it be the destination or
>> content in your message, I don't know.  See if they can add the
>> destination to the whitelist (acceptable list).
>> 
>> Beez
>> ( 4961 
>> 
>> -Original Message-
>> From: Richa Pandharikar [mailto:rich...@gmail.com]
>> Sent: Friday, December 19, 2008 6:20 PM
>> To: user@struts.apache.org
>> Subject: Bean Properties are lost
>> 
>> 
>> I have a User Object that I am using as a Bean in an Action.
>> 
>> User Object has following properties - 
>> 
>> firstName
>> lastName
>> username
>> password
>> collection roles
>> projects
>> 
>> 
>> Roles data is no where displayed on the JSP page. Project data is
>> displayed but I am using the plain ids to render the select tag. In the
>> jsp the firstName, lastName, username, password pro

Re: logic:iterate not populating the values on submit

2008-12-24 Thread Yayo
I think it's wrong... you don't need an "iterated" in order to set a single
simple value. With a setter and getter pair for the property is just enough.
You should be expecting an String with the given value from the user input.

The again I may be wrong... ^^

Happy new year!

--
 *Yayo*
http://yayocaturas.blogspot.com
eduy...@gmail.com
--



On Wed, Dec 24, 2008 at 7:43 PM, Prasanth Nair  wrote:

> Hi,
> I need a urgent help. Could someone respond to
>
>
> http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=015067
>
> regards
> Prasanth
>



-- 
"Noli nothis permittere te terere"

http://yayocaturas.blogspot.com/


logic:iterate not populating the values on submit

2008-12-24 Thread Prasanth Nair
Hi,
I need a urgent help. Could someone respond to

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=58&t=015067

regards
Prasanth


Overriding Struts UI Controls

2008-12-24 Thread Ganesh123

Hi,

 i am overriding the struts UI controls for my role based UI rendering.
based on user role i have to decide few attributes of UI component like
editability,visibility etc. for that i have implemented logic required. to
achieve this i am extending TextFieldTag and in the overriding method
doStartTag i am applying the attributes defined for every field. 

now the problem is.. when a UI control visibility is false, i want to create
a hidden field instead of rendering the component itself. see the code
snippent..
@override
public int doStartTag() throws JspException {
---
---
---
if(fieldname==null){
super.doStartTag();
}else if(fieldname!=null &&
fieldManager.getVisibility(fieldname,formAccessMode)){
super.doStartTag();
}else{ 
HiddenTag hiddenTag=new HiddenTag();
hiddenTag.setName(name);
hiddenTag.setValue(value);
hiddenTag.doStartTag(); 
  }

but hiddenTag.doStartTag() is throwing null pointer exception. 


java.lang.NullPointerException
at org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:52)
at
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:47)
at
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)

can any one help me ... how to solve this issue? what i am missing here? 
-- 
View this message in context: 
http://www.nabble.com/Overriding-Struts-UI-Controls-tp21156832p21156832.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Struts 2 Type Conversion for properties of a List

2008-12-24 Thread Paweł Wielgus
Hi Titus,
You can validate with annotations.

best greetings,
Pawel Wielgus

2008/12/24, Marsman :
>
>
> newton.dave wrote:
>>
>>
>>> if (   values[0] == null || values[0].length() == 0
>>> && values[0].equalsIgnoreCase("v.a.")
>>  || values[0].equalsIgnoreCase("various artists"))
>>
>> This condition strikes me as odd... did you really mean "&&" there?
>>
>
> No, of course not. You found an old bug in my converter at that time written
> for a JSF application. Apperently this bug was never a problem. :thinking:
>
> Titus
>
> --
> View this message in context:
> http://www.nabble.com/Struts-2-Type-Conversion-for-properties-of-a-List-tp21144957p21156808.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Struts 2 Type Conversion for properties of a List

2008-12-24 Thread Marsman


newton.dave wrote:
> 
> 
>> if (   values[0] == null || values[0].length() == 0 
>> && values[0].equalsIgnoreCase("v.a.")
>          || values[0].equalsIgnoreCase("various artists"))
> 
> This condition strikes me as odd... did you really mean "&&" there?
> 

No, of course not. You found an old bug in my converter at that time written
for a JSF application. Apperently this bug was never a problem. :thinking:

Titus

-- 
View this message in context: 
http://www.nabble.com/Struts-2-Type-Conversion-for-properties-of-a-List-tp21144957p21156808.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Struts 2 Type Conversion for properties of a List

2008-12-24 Thread Marsman


dusty wrote:
> 
> You could create a special class for this property so you can use type
> conversion but that seems ugly.
> 
> You are better off using EL or a custom tag for rendering the property. 
> 

I thought about creating a new type (in Hibernate) for my "artists". But
only for storing "various artists" as null in the database, this seems to me
a little bit overdone. However I've to do some more complicated conversions
than this one and using the struts conversion for artists was only a trial.

Maybe I will write a custom tag to do the conversion.

By the way: Does anybody know, why they are using xml to define validators
and the old school property files for conversions?

Thanks, Titus


-- 
View this message in context: 
http://www.nabble.com/Struts-2-Type-Conversion-for-properties-of-a-List-tp21144957p21156805.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Struts2 Error.

2008-12-24 Thread Srinivasan KS
hi,
I am trying to run the struts2 sample application. I am using Jdeveloper 11g
IDE with weblogic server.

I am getting this error, when I am running the application.