Re: convert string to object?
Re: convert string to object?
- Subject: Re: convert string to object?
- From: "Janice M. Cheung" <email@hidden>
- Date: Mon, 01 Dec 2003 13:17:24 -0500
Hi Arturo,
My menu consists of three dropdown lists.
The first list, Institution, is a hard-coded list of Strings to
limit the search within
only a few distinct Institutions.
The second list, Department, is an NSArray list of Department names
of type Department, converted to strings:
values = (NSDictionary)array.objectAtIndex(i);
obj = values.objectForKey("DEPARTMENT_NAME");
strDeptName=obj.toString();
allDeptName.addObject(strDeptName);
The third list, Division, is an NSArray of Department objects,
binding the Department selection to an
instance variable of selectedDivision, as you recommended.
public void fetchDvDepts(){
String qualifier;
qualifier = "institution.institutionLabel = ' " + m_InstSelected
+ " ' and departmentName = ' " +m_strDvDeptSelected + " ' ";
EOQualifier qual =
EOQualifier.qualifierWithQualifierFormat(qualifier, null);
NSMutableArray sort = new NSMutableArray();
EOSortOdering order 1 = new EOSortOrdering("divisionName",
EOSortOrdering.CompareAscending);
sort.addObject(order1);
EOFetchSpecification spec = new
EOFetchSpecification("Department", qual,sort);
EOEditingContext context =
((Session)session()).defaultEditingContext();
NSArray results = context.objectsWithFetchSpecification(spec);
setM_dvDepts(results);
}
My PDF reports work with the Division dropdown list (sets
selectedDivision to selected object from
the array) -- but for SuperUsers the reporting utility has to also
work for larger datasets, such as all
Departments (including Divisions) for selectedDepartment, and all
Institutions (including all Departments and
Divisions) for selectedInstitution.
Is there any alternative aside from using formatters?
Thanks!
Janice
arturo wrote:
>You need to look at how to use formatters. The base class is
>java.text.Format.
>
>But in addition to this you're not using the dropdown list in the most
>optimal way.
>You should be binding the list variable to an NSArray of your objects
>(Department
>in this case?). You should be binding the display variable to something
>that turns
>the Department object into a string (toString would work). And you need to
>bind
>the selection variable to an instance variable of selectedDepartment. Then
>the list
>will automatically set selectedDepartment to selected object from the array.
>
>If you follow the above approach then you won't need formatters.
>----- Original Message -----
>From: "Janice M. Cheung" <email@hidden>
>Cc: <email@hidden>; <email@hidden>
>Sent: Monday, December 01, 2003 12:48 PM
>Subject: convert string to object?
>
>
>
>
>> Hi there,
>>
>> Is there a simple function to convert a string to an object?
>>
>> I am attempting to use something like this for outputting PDFs in
>>WebObjects, so that
>> any selections from a dropdown menu (String type) will create those
>>selected Objects
>> in a report:
>>
>> Here is one of my functions to change selected String values into
>>objects of type Department:
>>
>> public java.lang.String toObject(){
>> String currentDept;
>> currentDept = toObject();
>> return currentDept;
>> }
>>
>> I've also tried to set string types in Search.java and set them in
>>Session.java to type Department, to
>> no avail:
>>
>> --- Search.java
>> String m_currentDept;
>> s.setCurrentDepartment(m_currentDept);
>>
>> (basically I want "currentDept" to be converted to type Department)
>>
>> --- Session.java
>> public Department currentDepartment(String currentDept){
>> return currentDepartment;
>> }
>>
>> public Department getCurrentDepartment(String currentDept){
>> return currentDepartment;
>> }
>>
>> public void setCurrentDepartment(Department newCurrentDepartment){
>> currentDepartment=newCurrentDepartment;
>> }
>>
>> These string values are retrieved as qualifiers from the database...
>>any advice or guidance
>> would be greatly appreciated!!
>>
>> Thanks very much!
>>
>> Happy Happy Holidays!
>>
>> Janice
>>
>>_______________________________________________
>>WebObjects-dev mailing list
>>email@hidden
>>http://www.omnigroup.com/mailman/listinfo/webobjects-dev
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.