掲示板

<alloy:commandButton> is not calling managed bean action

9年前 に ramathulasi kudumula によって更新されました。

<alloy:commandButton> is not calling managed bean action

Junior Member 投稿: 51 参加年月日: 11/10/06 最新の投稿
Hi,

I am trying to implement the <alloy:commandButton> in liferay portal 6.2. When i click the submit button the managed bean action or actionListener is not calling. But the same is working in Liferay Faces Alloy demo site.
View.xhtml Code:
============
<?xml version="1.0" encoding="UTF-8"?>
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:alloy="http://liferay.com/faces/alloy"
xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets">
<alloy:head />
<alloy:body>
<alloy:form>
<alloy:commandButton actionListener="#{sampleBackingBean.actionListener}" immediate="true"
value="submit">
<f:ajax execute="@form" render="@form" />
</alloy:commandButton>
<alloy:outputText value="#{sampleBackingBean.text}" />
</alloy:form>
</alloy:body>
</f:view>

SampleBackingBean.java Code:
==========================

package com.tsky.selfcare.sampleportlet;


import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.event.ActionEvent;

import com.liferay.faces.util.logging.Logger;
import com.liferay.faces.util.logging.LoggerFactory;

@ManagedBean(name="sampleBackingBean")
@RequestScoped
public class SampleBackingBean {

private static final Logger logger = LoggerFactory.getLogger(SampleBackingBean.class);
private String text;


public String getText() {
return text;
}


public void setText(String text) {
this.text = text;
}


public void actionListener(ActionEvent actionEvent) {
logger.debug("Entered into actionListener");
logger.info("Entered into actionListener");
text="Hiiiiiii";
}
}
It would be helpful if some one share sample working code for this.

Regards
Thulasi
thumbnail
9年前 に Juan Gonzalez によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Hi ramathulasi,

you don't need

immediate="true"


in your commandButton. Please remove it.

Additionally adding

execute="@form"


isn't needed in your test case. You can safely remove it.

Last thing you can check, did you add

<requires-namespaced-parameters>false</requires-namespaced-parameters>


to your liferay-portlet.xml?

Thanks.
9年前 に ramathulasi kudumula によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Junior Member 投稿: 51 参加年月日: 11/10/06 最新の投稿
Thanks Juan..

Its working fine after adding <requires-namespaced-parameters>false</requires-namespaced-parameters> in liferay-portlet.xml file.

But i am facing another issue..I want to pass the parameter to bean action when i click the alloy:commandButton.
When i include the f:param inside alloy:commandButton the button itself not showing on the browser.

xhtml code :
=========
<alloy:commandButton action="#{sampleBackingBean.callPopup}" value="Submit">
<f:param name="sampleText" value="Hello"></f:param>
</alloy:commandButton>

Bean Code:
==========
public String callPopup()
{
String name="";
FacesContext fc = FacesContext.getCurrentInstance();
Map<String,String> params = fc.getExternalContext().getRequestParameterMap();
name = params.get("sampleText");
return null;
}
Regards
Thulasi
thumbnail
9年前 に Juan Gonzalez によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Hi again,

seems you declared a local variable "name" and you stored the param value there. Probably you want to store in a class attribute and have setters and getters to render in the xhtml.
9年前 に ramathulasi kudumula によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Junior Member 投稿: 51 参加年月日: 11/10/06 最新の投稿
Hi Juan,

I am trying to implement pass a parameter to bean action method on clicking a link or button.

In my code the parameter name is sampleText and name which is declared a local variable in my bean.
Here i am storing the parameter value in name variable only.

But my question is not able to pass the parameter to bean using f:param tag inside alloy:commandButton/CommandLink.

Regards
Thulasi
thumbnail
9年前 に Juan Gonzalez によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Hi,

yes, I understood the question the first time emoticon.

It's working fine for me, my question is, why do you think isn't working? And that's why I said my thoughts that you are rendering the wrong managed bean attribute.
8年前 に ramathulasi kudumula によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Junior Member 投稿: 51 参加年月日: 11/10/06 最新の投稿
Hi Juan,

Can you please share the working code?

Regards
Thulasi
thumbnail
8年前 に Juan Gonzalez によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
ramathulasi kudumula:
Hi Juan,

Can you please share the working code?

Regards
Thulasi


The alloy:commandButton snippet is same as yours. Please answer my question about how do you know it isn't working for you.

Thanks.
8年前 に ramathulasi kudumula によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Junior Member 投稿: 51 参加年月日: 11/10/06 最新の投稿
ramathulasi kudumula:

xhtml code :
=========
<alloy:commandButton action="#{sampleBackingBean.callPopup}" value="Submit">
<f:param name="sampleText" value="Hello"></f:param>
</alloy:commandButton>

Bean Code:
==========
public String callPopup()
{
String name="";
FacesContext fc = FacesContext.getCurrentInstance();
Map<String,String> params = fc.getExternalContext().getRequestParameterMap();
name = params.get("sampleText");
return null;
}




I am trying to fetch the param value in action method as shown above. But the param value is not getting passed as expected. Button is also going to hidden mode.
thumbnail
8年前 に Juan Gonzalez によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Please can you attach your portlet so I can make some checks?

Thanks.
8年前 に ramathulasi kudumula によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Junior Member 投稿: 51 参加年月日: 11/10/06 最新の投稿
I am attaching portlet code.

Regards
Thulasi
thumbnail
8年前 に Juan Gonzalez によって更新されました。

RE: <alloy:commandButton> is not calling managed bean action

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Hi ramathulasi,

thanks to you feedback we found that this was a bug caused by not adding other commandLink/commandButton to the page.

We fixed it here: https://issues.liferay.com/browse/FACES-2196

Thanks again!