MenuItem Dinamic doesn't work Ajax

UI Components for JSF
Post Reply
77713777
Posts: 17
Joined: 14 Jul 2010, 21:28
Location: Brasil
Contact:

16 Mar 2011, 13:34

Hi, help me please,
I'm make one menu dinamic, it,s wok's ok!
But no with call Ajax, it's rendering the entire page.

My code!

Code: Select all

// code Java
// Properties BeanController
private DefaultMenuModel                model;

//In metod
private void processMenuDinamic()
{
     model = new DefaultMenuModel();
     Submenu submenuAdress =  new Submenu();
     submenuAdress.setLabel("Adress");
     MenuItem item = new MenuItem();
     item.setProcess("@this");
     item.setUpdate("pageConteudo");
     item.setUrl(url);
     item.setValue(keyI18N);
     item.setAjax(true);
     item.setAsync(true);
     submenuAdress.getChildren().add(item);
     model.addSubmenu(submenuAdress);
}

Code: Select all

// this code in .xhtml
           <div id="sider" class="sidebar">    	
        	<h2>#{msgs.menuUsers } </h2>			
		<p:menu id="menusUser" widgetVar="tieredMenu" context="'start','tl','br'" effectDuration="10"  tiered="true" style="width:170px" model="#{login.model}"/>  
	  </div>   
What should I do for this submenu work with ajax?

77713777
Posts: 17
Joined: 14 Jul 2010, 21:28
Location: Brasil
Contact:

17 Mar 2011, 13:13

Anyone can help me with this problem?

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

17 Mar 2011, 13:37

Hi,

I guess, it's by reason of item.setUrl(url); Try to set Action / ActionListener (as MethodExpression). URL is for non Ajax requests.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

17 Mar 2011, 13:54

Yes, you need to create a MethodExpression and set it as the actionExpression. Remove url usage as Oleg said.

77713777
Posts: 17
Joined: 14 Jul 2010, 21:28
Location: Brasil
Contact:

17 Mar 2011, 14:47

Hi, thanks -
Oleg the metodo action that is deprecated.

This method takes as a parameter of type Object MethodBinding
I do not create an object as well
Could you show me?

As for the ActionListener as would a call to a page
. xhtml, to know how to have an object that is redirecting to that url
desire ... but then come back to the previous problem ...

the call has to be Ajax.

Code: Select all

<a onclick="PrimeFaces.ajax.AjaxRequest('/webPrime/mod/adress/countryes.jsf',      
     {formId:'form',async:true,global:true,source:'tablesysParents:0:j_idt124',process:'tablesysParents:0:j_idt124',update:'messages'});" href="javascript:void(0)" class="wijmo-wijmenu-link ui-corner-all">
    <span class="wijmo-wijmenu-text">
                       <span class="ui-icon ui-icon-disk wijmo-wijmenu-icon-left"></span>
                       <span class="wijmo-wijmenu-text">Save</span>
    </span>
</a>
I'm needing PrimeFaces that manages the hunt similar to what has in onclick

77713777
Posts: 17
Joined: 14 Jul 2010, 21:28
Location: Brasil
Contact:

17 Mar 2011, 16:26

I'm tray

This code...

Code: Select all

FacesContext facesCtx = FacesContext.getCurrentInstance();
		ELContext elCtx = facesCtx.getELContext();
		ExpressionFactory expFact = facesCtx.getApplication().getExpressionFactory();
		
		
		MenuItem item = new MenuItem();
		item.setProcess("@this");
		item.setUpdate("pageConteudo");
		item.setValue(keyI18N);
		item.setActionExpression(expFact.createMethodExpression(elCtx, url, String.class, new Class[0]));
But my code HTML. does't has my url, have the URL current page!

See HTML code Inspction with fireBug.

Code: Select all

<a onclick="PrimeFaces.ajax.AjaxRequest('/webPrime/mod/home.jsf',{formId:'form',async:false,global:true,source:'menus:j_id10',process:'menus:j_id10',update:'pageConteudo'});" href="javascript:void(0)" class="wijmo-wijmenu-link ui-corner-all"><span class="wijmo-wijmenu-text"><span class="wijmo-wijmenu-text">Cidades</span></span></a>
This URL is not what I print,
The URL this. http://localhost:8080/webPrime/mod/adress/citys.jsf

What should I do to set this url in place of that which is appearing in an HTML?
/webPrime/mod/home.jsf for this http://localhost:8080/webPrime/mod/adress/citys.jsf

77713777
Posts: 17
Joined: 14 Jul 2010, 21:28
Location: Brasil
Contact:

18 Mar 2011, 15:24

Anybody...?

How do this?
i`m don't know!

77713777
Posts: 17
Joined: 14 Jul 2010, 21:28
Location: Brasil
Contact:

21 Mar 2011, 23:05

can anyone help me ....
it is difficult even

Please...

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

22 Mar 2011, 10:35

Hi,

If you do an Ajax call, the URL is the URL of the current page. HTML PrimeFaces.ajax.AjaxRequest('/webPrime/mod/home.jsf' ... is correct in my opinion. Otherwise you need to have non Ajax calls (item.setAjax(false); item.setUrl(...)).
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

77713777
Posts: 17
Joined: 14 Jul 2010, 21:28
Location: Brasil
Contact:

22 Mar 2011, 13:47

Thanks Oleg, but are not understanding me
I need the call is Ajax.

My menu is dynamic, it is created as the levels of user access.
My homepage is http://localhost:8080/webPrime/mod/home.jsf.

Other examples of pages
http://localhost:8080/webPrime/mod/adress/adresses.jsf
http://localhost:8080/webPrime/mod/adress/state.jsf

that are submenus, which should make Ajax calls
and are rendered in a tag on the front page of the DOM.

I do not know the method setActionExpression set to call for example the two above URL in the submenu with Ajax.


That URL, is the URL that appears not I put in setActionExpression
but the actual URL of the page
eg I put http://localhost:8080/webPrime/mod/adress/adresses.jsf
understood but appears http://localhost:8080/webPrime/mod/home.jsf not know what else to do with it

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 53 guests