Re: Using DataGrid in WO
Re: Using DataGrid in WO
- Subject: Re: Using DataGrid in WO
- From: Chuck Hill <email@hidden>
- Date: Tue, 02 Aug 2011 20:22:32 -0700
Hi Michael,
On 2011-08-01, at 2:21 PM, Michael Gargano wrote:
> Hey Chuck,
>
> This is from a few months ago, but how exactly are you passing your selected row into the dialog to edit it? I can't figure this out since I'm using a custom cell in the grid to do this. the custom cell has an ajaxmodaldialogopener with an image in it.
>
> are you just directly using ajaxmodaldialogopener as the custom component?
No. Here is a class that I have been using as the superclass of the components in a grid. You may find it useful:
package net.foo.core.web;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.foundation.*;
import er.ajax.*;
/**
* Optional super-class for components that appear in cells in the AjaxGrid.
*/
public class AjaxGridCell extends WOComponent
{
private String rowIndex;
/**
* Basic class constructor.
*
* @param context of current page
*/
public AjaxGridCell(WOContext context)
{
super(context);
}
/**
* @return true as this component is stateless and non-synchronizing
*/
public boolean isStateless()
{
return true;
}
/**
* Nulls optimization variables.
*/
public void reset()
{
rowIndex = null;
}
/**
* @return object bound to <code>value</code>
*/
public Object value()
{
return valueForBinding("value");
}
/**
* @return AjaxGrid bound to <code>grid</code>
*/
public AjaxGrid grid()
{
return (AjaxGrid) valueForBinding("grid");
/** ensure [valid_result] Result != null; **/
}
/**
* @return object bound to grid <code>row</code>
*/
public EOEnterpriseObject object()
{
return (EOEnterpriseObject)grid().row();
}
/**
* @return grid()'s configurationData()
*/
public NSMutableDictionary configurationData()
{
return grid().configurationData();
/** ensure [valid_result] Result != null; **/
}
/**
* @return grid()'s displayGroup()
*/
public WODisplayGroup displayGroup()
{
return grid().displayGroup();
/** ensure [valid_result] Result != null; **/
}
/**
* @return grid()'s editingContext()
*/
public EOEditingContext editingContext()
{
return displayGroup().dataSource().editingContext();
/** ensure [valid_result] Result != null; **/
}
/**
* @return updateContainerID for AjaxActionLinks in this grid
*/
public String updateContainerID()
{
return (String) configurationData().objectForKey(AjaxGrid.UPDATE_CONTAINER_ID);
/** ensure [valid_result] Result != null; **/
}
/**
* @return returns index for the current row that can be used to create unique IDs for HTML
*/
public String rowIndex()
{
if (rowIndex == null)
{
int index = displayGroup().displayedObjects().indexOfObject(object());
rowIndex = String.valueOf(index);
}
return rowIndex;
/** ensure [valid_result] Result != null; **/
}
/**
* Return unique ID for this row in the grid. This is to be used to build unique IDs for each row.
*
* @return unique ID for this row in the grid
*/
public String rowID()
{
return grid().rowID();
/** ensure [valid_result] Result != null; **/
}
}
The AMD Opener then stashes object() in the thread/page/session/as you like for the dialog to use. My pages have a concept of "selected object" or "focused object"
> also, this is probably a dumb question, but there's no way to pop and push modal dialogs on top of one another? My spec calls for a modal dialog that has another modal on top of it for selection inside the 1st modal dialog (i just work here).
:-)
> i starting writing a component myself, but when I needed to make it ajax-y i turned and started running the other way.
I don't think there is a way. The reason is that the underlying JavaScript implementation just allows for one to be displayed at a time. You would have to close one and open the other, or update the contents of the current one with the other one. I'd look at that or something like an expansion area.
Chuck
> On May 25, 2011, at 1:37 PM, Chuck Hill wrote:
>
>> Hi Raymond,
>>
>>
>> On May 25, 2011, at 3:10 AM, <email@hidden> <email@hidden> wrote:
>>
>>> Hi Chuck,
>>>
>>> this is my html :
>>> <wo:tPopUpButton list="$personList" item="$person" value="$selectedPerson"/>
>>> <wo:AjaxModalDialogOpener id="refreshGrid">
>>>
>>> <wo:AjaxSubmitButton action="$addSelectedPerson" value="addPerson">
>>>
>>> </wo:AjaxModalDialogOpener>
>>>
>>> <webobject name=personNavBar">
>>> <webobject name"personGrid">
>>>
>>> and this is my WOD
>>>
>>> personGrid : AjaxGrid {
>>> configurationData = personDataConfig;
>>> displayGroup = personDg;
>>> afterUpdate = "personNavBarUpdate();";
>>> }
>>>
>>> NavBarPerson : AjaxGridNavPersonBar {
>>> containerID = "NavBarPerson";
>>> displayGroup = personDg;
>>> configurationData = personDataConfig;
>>> }
>>>
>>> I don't use AjaxModalDialog but AjaxModalDialogOpener.
>>
>> But... you do have an AjaxModalDialog that the AjaxModalDialogOpener is opening, right? If you don't, you are not using the AjaxModalDialogOpener correctly. If you do have an AjaxModalDialog (even if it is in a different component), then the closeUpdateContainerID goes in that WOD definition.
>>
>>
>>> Can I surround AjaxModalDialogOpener with AjaxModalDialog ?
>>
>> No. See how they are used in the AjaxExamples application in Wonder. You also should not have a submit button inside the AjaxModalDialogOpener:
>>
>>> <wo:AjaxModalDialogOpener id="refreshGrid">
>>>
>>> <wo:AjaxSubmitButton action="$addSelectedPerson" value="addPerson">
>>>
>>> </wo:AjaxModalDialogOpener>
>>
>>
>>
>>> Where I insert AjaxModalDialog in my code to refresh my grid? My AjaxModalDialogOpener is on the good side in html code?
>>
>> The AjaxModalDialog was to edit the information shown in your grid.
>>
>>
>> Chuck
>>
>>
>>>
>>> Message du : 25/05/2011
>>> De : "Chuck Hill " <email@hidden>
>>> A : email@hidden
>>> Copie à : email@hidden
>>> Sujet : Re: Using DataGrid in WO
>>>
>>>
>>> In the plist that has your grid configuration, add a line like this:
>>> updateContainerID = "resultsContainer";
>>>
>>> Then in the WOD that defines the dialog:
>>> MyDialog : AjaxModalDialog {
>>> closeUpdateContainerID = "resultsContainer";
>>>
>>>
>>> Chuck
>>>
>>>
>>> On May 20, 2011, at 12:34 PM, <email@hidden> <email@hidden> wrote:
>>>
>>>> Hi Chuck,
>>>>
>>>> Can you give me an example, I don't know how to introduce it in my code.
>>>>
>>>> Thanks
>>>>
>>>>
>>>> ========================================
>>>>
>>>> Message du : 20/05/2011
>>>> De : "Chuck Hill " <email@hidden>
>>>> A : email@hidden
>>>> Copie à : email@hidden
>>>> Sujet : Re: Using DataGrid in WO
>>>>
>>>>
>>>> Use the closeUpdateContainerID binding on the AjaxModalDialog.
>>>>
>>>>
>>>> On May 20, 2011, at 6:07 AM, <email@hidden> wrote:
>>>>
>>>>> Hi Chuck,
>>>>>
>>>>> I try to follow your advice but I have some problems.
>>>>>
>>>>> In HTML (my textfield and button using to add person in my Grid: )
>>>>>
>>>>> <wo:tPopUpButton list="$personList" item="$person" value="$selectedPerson"/>
>>>>> <wo:AjaxModalDialogOpener id="refreshGrid">
>>>>> <wo:AjaxSubmitButton action="$addPerson" value="add">
>>>>> </wo:AjaxModalDialogOpener>
>>>>> <webobject name=personNavBar">
>>>>> <webobject name"personGrid">
>>>>>
>>>>> In WOD
>>>>> ...
>>>>> personGrid : AjaxGrid {
>>>>> configurationData = personDataConfig;
>>>>> displayGroup = personDg;
>>>>> afterUpdate = "personNavBarUpdate();";
>>>>> }
>>>>>
>>>>> in java class
>>>>> ... variable declaration
>>>>>
>>>>> public WOActionResults addPerson(){
>>>>> personDg = new WODisplayGroup();
>>>>> persondg.setObjectArray(PersonData(selectedPerson.fullname));
>>>>> }
>>>>>
>>>>> private NSMutableArray PersonData(String aPerson) {
>>>>> NSMutableDictionnary personDico = new NSMutableDictionnary ();
>>>>> if(aPerson.equals(null)){
>>>>> return null;
>>>>> }
>>>>> personDico.takeValueForKey(aPerson, "persnoFullname 1");
>>>>>
>>>>> return (NSMutableArray) personDico.allValues();
>>>>> }
>>>>>
>>>>> My question is How to refresh my Grid to know if the person I added is present in the grid?
>>>>>
>>>>> Thanks
>>>>> ========================================
>>>>>
>>>>> Message du : 19/05/2011
>>>>> De : "Chuck Hill " <email@hidden>
>>>>> A : email@hidden
>>>>> Copie à : email@hidden
>>>>> Sujet : Re: Using DataGrid in WO
>>>>>
>>>>>
>>>>> I have never added data directly in a grid. You would need to create a new object in the display group that the grid is using and use AjaxInPlace fields to edit the data. Instead, I use an AjaxModalDialogOpener in the grid and an AjaxModalDialog to add or edit one object. When the modal dialog closed, it refreshes the grid.
>>>>>
>>>>> Chuck
>>>>>
>>>>>
>>>>> On May 19, 2011, at 10:31 AM, <email@hidden> wrote:
>>>>>
>>>>>> Hi Chuck,
>>>>>>
>>>>>> I want to fill my AjaxGrid by adding data using textField and submitButton.
>>>>>>
>>>>>> How my addData() method can look like? I want to add person by company (PopUpButton with companies).
>>>>>> my configData file .plist is :
>>>>>>
>>>>>> {
>>>>>> tableID = "personGrid";
>>>>>> updateContainerID = "ajaxGridContainer";
>>>>>> sortable = true;
>>>>>> canReorder = true;
>>>>>> batchSize = 4;
>>>>>> cssClass = "ajaxGridTab";
>>>>>> cssStyle = "border: thin solid #000000;";
>>>>>> evenRowCSSClass = "none";
>>>>>> oddRowCSSStyle = "background:lightgrey;";
>>>>>> selectedRowCSSStyle = "font-weight: bold;";
>>>>>> selectedRowCSSClass = "ajaxGridSelectedRow";
>>>>>> rowIdentifier = number;
>>>>>> dragHeaderOnly = true;
>>>>>> columns = (
>>>>>> {
>>>>>> title = "Apple";
>>>>>> keyPath = "personFullName 1";
>>>>>>
>>>>>> },
>>>>>> {
>>>>>> title = "Microsoft";
>>>>>> keyPath = "personFullName 2";
>>>>>> },
>>>>>> {
>>>>>> title = "Rim";
>>>>>> keyPath = "personFullName 3";
>>>>>> },
>>>>>> {
>>>>>> title = "Google";
>>>>>> keyPath = "personFullName 4";
>>>>>> }
>>>>>> );
>>>>>> sortOrder = (
>>>>>> {
>>>>>> keyPath = "personFullName 1";
>>>>>> direction = "descending";
>>>>>> },
>>>>>> {
>>>>>> keyPath = "personFullName 2";
>>>>>> direction = "ascending";
>>>>>> }
>>>>>> );
>>>>>>
>>>>>> }
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> Ray
>>>>>>
>>>>>> ========================================
>>>>>>
>>>>>> Message du : 19/05/2011
>>>>>> De : "Chuck Hill " <email@hidden>
>>>>>> A : email@hidden
>>>>>> Copie à : email@hidden
>>>>>> Sujet : Re: Using DataGrid in WO
>>>>>>
>>>>>>
>>>>>> That is the default. You could make an extension to get that information elsewhere.
>>>>>>
>>>>>> Chuck
>>>>>>
>>>>>>
>>>>>> On May 19, 2011, at 1:14 AM, <email@hidden> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> it's necessary to use a .plist file to configure the AjaxGrid configurationData?
>>>>>>>
>>>>>>>
>>>>>>> ========================================
>>>>>>>
>>>>>>> Message du : 19/05/2011
>>>>>>> De : "Stefan Klein " <email@hidden>
>>>>>>> A : email@hidden
>>>>>>> Copie à :
>>>>>>> Sujet : Re: Using DataGrid in WO
>>>>>>>
>>>>>>>
>>>>>>> You can find an online demo under http://wiki.objectstyle.org/confluence/display/WONDER/Example+Applications.
>>>>>>> Choose AjaxExample -> Online demo.
>>>>>>>
>>>>>>> Using the link AjaxExample you will see the source code.
>>>>>>>
>>>>>>> Stefan
>>>>>>>
>>>>>>> Am 19.05.11 08:41, schrieb email@hidden:
>>>>>>>> Hi Chuck,
>>>>>>>>
>>>>>>>> Do you have an example how to use it?
>>>>>>>>
>>>>>>>>
>>>>>>>> ========================================
>>>>>>>>
>>>>>>>> Message du : 18/05/2011
>>>>>>>> De : "Chuck Hill " <email@hidden>
>>>>>>>> A : email@hidden
>>>>>>>> Copie à : email@hidden
>>>>>>>> Sujet : Re: Using DataGrid in WO
>>>>>>>>
>>>>>>>>
>>>>>>>> There is an AjaxGrid component in the Ajax framework in Wonder. That might give you what you want.
>>>>>>>>
>>>>>>>> Chuck
>>>>>>>>
>>>>>>>>
>>>>>>>> On May 18, 2011, at 11:52 AM, email@hidden wrote:
>>>>>>>>
>>>>>>>>> it possible to use a DataGrid in a WebObjects project like Wonder or other? Is there a special framework to use it?
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>>
>>>>>>>>> Ray
>>>>>>>>
>>>>>>>> --
>>>>>>>> Chuck Hill Senior Consultant / VP Development
>>>>>>>>
>>>>>>>> Come to WOWODC this July for unparalleled WO learning opportunities and real peer to peer problem solving! Network, socialize, and enjoy a great cosmopolitan city. See you there! http://www.wocommunity.org/wowodc11/
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> Chuck Hill Senior Consultant / VP Development
>>>>>>
>>>>>> Come to WOWODC this July for unparalleled WO learning opportunities and real peer to peer problem solving! Network, socialize, and enjoy a great cosmopolitan city. See you there! http://www.wocommunity.org/wowodc11/
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> Chuck Hill Senior Consultant / VP Development
>>>>>
>>>>> Come to WOWODC this July for unparalleled WO learning opportunities and real peer to peer problem solving! Network, socialize, and enjoy a great cosmopolitan city. See you there! http://www.wocommunity.org/wowodc11/
>>>>>
>>>>>
>>>>
>>>> --
>>>> Chuck Hill Senior Consultant / VP Development
>>>>
>>>> Come to WOWODC this July for unparalleled WO learning opportunities and real peer to peer problem solving! Network, socialize, and enjoy a great cosmopolitan city. See you there! http://www.wocommunity.org/wowodc11/
>>>>
>>>>
>>>
>>> --
>>> Chuck Hill Senior Consultant / VP Development
>>>
>>> Come to WOWODC this July for unparalleled WO learning opportunities and real peer to peer problem solving! Network, socialize, and enjoy a great cosmopolitan city. See you there! http://www.wocommunity.org/wowodc11/
>>>
>>>
>>
>> --
>> Chuck Hill Senior Consultant / VP Development
>>
>> Come to WOWODC this July for unparalleled WO learning opportunities and real peer to peer problem solving! Network, socialize, and enjoy a great cosmopolitan city. See you there! http://www.wocommunity.org/wowodc11/
>>
>> <smime.p7s><ATT00001..txt>
>
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden