Hi Ramsey,
I managed to create a three-level menu using specific actions in the navigation controller and appropriate rules. The beauty of the solution is that I have to perform the queries with an additional qualifier based on at least one session global and this method allowed me to do this with easy. The following example shows it:
public WOComponent listPacotesAction() { ListPageInterface component = D2W.factory().listPageForEntityNamed(Pacote.ENTITY_NAME, session()); EODatabaseDataSource ds = new EODatabaseDataSource(session().defaultEditingContext(), Pacote.ENTITY_NAME); agênciaAuxiliaryQualifier(ds, null); component.setDataSource(ds); if (component instanceof D2WPage) { D2WPage page = (D2WPage)component; page.d2wContext().takeValueForKey("Produtos.Pacotes.ListarPacotes", "navigationState"); } return (WOComponent)component; }
private void agênciaAuxiliaryQualifier(EODatabaseDataSource ds, EOQualifier additionalQualifier) { Session s = (Session) session(); long agênciaID = s.getUsuário().agência().agênciaID(); EOQualifier aq = EOQualifier.qualifierWithQualifierFormat("agênciaID = %d", new NSArray (new Object[] {agênciaID}));
if (additionalQualifier == null) { ds.setAuxiliaryQualifier(aq); } else { EOQualifier andQ = new EOAndQualifier(new NSArray(new Object[] {aq, additionalQualifier})); ds.setAuxiliaryQualifier(andQ); } }
100 : pageConfiguration like 'ListPacote' => navigationState = "Produtos.Pacotes.ListarPacotes" [com.webobjects.directtoweb.Assignment]
The queries must also performed with restrictions set by some session globals and I was able to accomplish this with the help of a query delegate and the auxiliary qualifier.
My love for WO and Wonder is growing everyday.
Angelo
Em 31/07/2012, às 13:50, Ramsey Gurley escreveu: Please keep questions/replies on list so that everyone may benefit/assist :-) On Jul 30, 2012, at 8:50 PM, Sr. Ângelo Andrade Cirino wrote: Dear Ramsey,
I am very frustrated. I created two new test projects following your steps in the presentation, choosing 'WO Project' from template and then 'Modern D2W Application', one project with the ERMovies Logic framework and the other with a very simple model I created (two entities with a to one relationship). But in both projects the navigation menu did not work.
You shouldn't need to do that any longer. If you create a new Wonder D2W project, it will be an ERModern project these days. Should I trash my installation, a brand new Eclipse/WOLips/Wonder standard installation, and try again? I can not see what I am doing wrong.
Sorry about that. The install process for WO/Wonder/WOLips just sucks. It's amazing to me that anyone new gives it a try. I saw sometime ago that Ken Ishimoto had been working on an installer, but I never had a chance to try it. We all muddled through this at one point, if that gives you any comfort :-) If your app launches, it's probably not your installation. Worse, not only the navigation menu doesn't work,
Did you try debugging your rule firings to see what was being set for navigationState and why? but also the tabs and sections features for grouping display properties. The following rule
100 : (entity.name = 'Pacote' and task = 'edit') => displayPropertyKeys = ("[Geral]", "encerramento", "título", "resumo", "títuloEstendido", "moeda", "descrição", "principal", "[Imagens]", "miniatura", "imagemPequena", "imagemGrande", "[Outras informações]", "opçãoIncluídas", "informaçãoAdicionals", "condiçãoPacotes") [com.webobjects.directtoweb.Assignment]
Gives this exception:
<com.webobjects.foundation.NSKeyValueCoding$UnknownKeyException message '<com.visionar.modelos.Pacote 0x461fbe88> valueForKey(): lookup of unknown key: '[Geral]'. This class does not have an instance variable of the name [Geral] or _[Geral], nor a method of the name [Geral], _[Geral], get[Geral], or _get[Geral]' object '<com.visionar.modelos.Pacote pk:"1">' key '[Geral]'>
To use tabs on a Modern page, you have to have a tab or wizard page configuration/subtask. Otherwise, it doesn't work. When you create the page, use a pageConfiguration like "EditTabEntity" or "EditWizardEntity" instead of "EditEntity". CreateEntity pages are subtask=wizard by default, so the tabbing should work. Ramsey D2W and the navigation system are way too powerful for me to not use them as the basis for WO development. I used to create components and a lot of code that can with a lot less work be designed with D2W applications and I would like to move forward, but having the navigation menu system and the properties display grouping working will help me a lot.
Thanx,
Angelo
Em 30/07/2012, às 16:46, Ramsey Gurley escreveu:
Well, I simplified the menu to just one level with four items to experiment with the rules. When selected, each menu is performing adequately, listing the entities it is meant to, with the associated action and D2W.factory().listPageForEntityNamed. But the menu system stubbornly do not highlight the chosen menu option, Principal is locked to be the highlighted menu. The menu and the associated rules are now these:
NavigationMenu.plist
(
{
name = Root;
children = (Principal,Pacotes,Clientes,Usuarios);
},
{
name = Principal;
action = "";
},
{
name = Pacotes;
action = "";
},
{
name = Clientes;
action = "";
},
{
name = Usuarios;
action = "";
}
)
user.d2wmodel rules associated with the menu items
{"author" = "100"; "class" = "com.webobjects.directtoweb.Rule"; "lhs" = {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "pageConfiguration"; "selectorName" = "isLike"; "value" = "*Usuario*"; }; "rhs" = {"class" = "com.webobjects.directtoweb.Assignment"; "keyPath" = "navigationState"; "value" = "Usuarios"; }; },
{"author" = "100"; "class" = "com.webobjects.directtoweb.Rule"; "lhs" = {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "pageConfiguration"; "selectorName" = "isLike"; "value" = "*Produto*"; }; "rhs" = {"class" = "com.webobjects.directtoweb.Assignment"; "keyPath" = "navigationState"; "value" = "Produtos"; }; },
{"author" = "100"; "class" = "com.webobjects.directtoweb.Rule"; "lhs" = {"class" = "com.webobjects.eocontrol.EOKeyValueQualifier"; "key" = "pageConfiguration"; "selectorName" = "isLike"; "value" = "*Clientes*"; }; "rhs" = {"class" = "com.webobjects.directtoweb.Assignment"; "keyPath" = "navigationState"; "value" = "Clientes"; }; },
I can not see what I am doing wrong so that the navigation menu isn't highlighting the selected option. But I also need to yet figure out how to create and use submenus.
Thanks,
Angelo
That looks like it should work. You need to debug your rule firings to see why nothing is happening.
Ramsey
|