Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 错误:找不到引用。将ActionListener方法绑定到<;中的按钮;自动对焦:按钮>;_Jsf_Parameter Passing_Actionlistener_Oracle Adf - Fatal编程技术网

Jsf 错误:找不到引用。将ActionListener方法绑定到<;中的按钮;自动对焦:按钮>;

Jsf 错误:找不到引用。将ActionListener方法绑定到<;中的按钮;自动对焦:按钮>;,jsf,parameter-passing,actionlistener,oracle-adf,Jsf,Parameter Passing,Actionlistener,Oracle Adf,我正在使用jdeveloper12c创建一个程序。该程序将使用用户生成的地址输入,然后在地图上标记该地址。使用的地图是Jdeveloper的专题地图功能。我遇到的问题是按钮的actionListener。它应该启动LLConverter类的addLocation方法,该方法接受输入(在RichInputText中),将其转换为纬度和经度(通过大量转换,RTF-->字符串(因此我可以使用GeoCoder转换为Lat和Long)--->float(用于专题地图),然后将这些值打印到映射上。无法识别A

我正在使用jdeveloper12c创建一个程序。该程序将使用用户生成的地址输入,然后在地图上标记该地址。使用的地图是Jdeveloper的专题地图功能。我遇到的问题是按钮的actionListener。它应该启动LLConverter类的addLocation方法,该方法接受输入(在RichInputText中),将其转换为纬度和经度(通过大量转换,RTF-->字符串(因此我可以使用GeoCoder转换为Lat和Long)--->float(用于专题地图),然后将这些值打印到映射上。无法识别ActionListener
{AddButton.addLocation}

这是我的两门课:

 public class LLConverter {

private static final String GEO_CODE_SERVER = "http://maps.googleapis.com/maps/api/geocode/json?";
private static RichInputText addressBind;

private List<LocationDetail> mapDetail = new ArrayList<LocationDetail>();

public LLConverter() {
        // Add Default location to map
        LocationDetail location = new LocationDetail();

        location.setLongitude((float) 105.0781);
        location.setLatitude((float) 40.5592);
        mapDetail.add(location);

        location = new LocationDetail();

        location.setLongitude((float) 91.5333);
        location.setLatitude((float) 41.6667);
        mapDetail.add(location);

        System.out.println("List is-" + mapDetail);
    }    
public void addLocation(ActionEvent actionEvent, String addressBind)throws IOException, BadLocationException{


        RTFEditorKit rtfParser = new RTFEditorKit();
        Document document = rtfParser.createDefaultDocument();
        ByteArrayInputStream bytearrayinputstream=new ByteArrayInputStream(addressBind.getBytes());
        rtfParser.read(bytearrayinputstream,document,0);
        String code = document.getText(0, document.getLength());

        String response = getLocation(code);

        String[] result = parseLocation(response);

        float[] numbers = new float[result.length];
            for (int i = 0; i < result.length; ++i) {
                float number = Float.parseFloat(result[i]);
                float rounded = (int) Math.round(number * 1000) / 1000f;
                numbers[i] = rounded;
            }
        float lat = numbers[0];
        float lon = numbers[1];

        LocationDetail location = new LocationDetail();
        location = new LocationDetail();
        location.setLongitude(lat);
        location.setLatitude(lon);
        mapDetail.add(location);



    System.out.println("List is-" + mapDetail);

}

public void setAddressBind(RichInputText addressBind) {
    this.addressBind = addressBind;
}

public RichInputText getAddressBind() {
    return addressBind;
}
private static String getLocation(String code)
{
    String address = buildUrl(code);

    String content = null;

    try
    {
        URL url = new URL(address);

        InputStream stream = url.openStream();

        try
        {
            int available = stream.available();

            byte[] bytes = new byte[available];

            stream.read(bytes);

            content = new String(bytes);
        }
        finally
        {
            stream.close();
        }

        return (String) content.toString();
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}

private static String buildUrl(String code)
{
    StringBuilder builder = new StringBuilder();

    builder.append(GEO_CODE_SERVER);

    builder.append("address=");
    builder.append(code.replaceAll(" ", "+"));
    builder.append("&sensor=false");

    return builder.toString();
}

private static String[] parseLocation(String response)
{
    // Look for location using brute force.
    // There are much nicer ways to do this, e.g. with Google's JSON library: Gson
    //     https://sites.google.com/site/gson/gson-user-guide

    String[] lines = response.split("\n");

    String lat = null;
    String lng = null;

    for (int i = 0; i < lines.length; i++)
    {
        if ("\"location\" : {".equals(lines[i].trim()))
        {
            lat = getOrdinate(lines[i+1]);
            lng = getOrdinate(lines[i+2]);
            break;
        }
    }

    return new String[] {lat, lng};
}

private static String getOrdinate(String s)
{
    String[] split = s.trim().split(" ");

    if (split.length < 1)
    {
        return null;
    }

    String ord = split[split.length - 1];

    if (ord.endsWith(","))
    {
        ord = ord.substring(0, ord.length() - 1);
    }

    // Check that the result is a valid double
    Double.parseDouble(ord);

    return ord;
}

public void setMapDetail(List mapDetail) {
this.mapDetail = mapDetail;
}

public List getMapDetail() {
return mapDetail;
}    
还有我的地图的代码,这是一个jsf页面

<af:document title="Map.jsf" id="d1">
    <af:form id="f1">
        <af:pageTemplate viewId="/oracle/templates/threeColumnTemplate.jspx" id="pt1"
                         >
            <f:facet name="center">
                <dvt:thematicMap basemap="usa" id="tm1" >
                    <?audit suppress oracle.adf.dvt.acc-compreqsummary?>
                    <dvt:areaLayer layer="counties" id="al1" />
                    <dvt:pointDataLayer id="dl1" value="#{viewScope.LLConverter.mapDetail}" var="row">
                        <dvt:pointLocation id="pl1"  type="pointXY" pointY="#{row.longitude}" 
                        pointX="#{row.latitude}">
                            </dvt:pointLocation>
                    </dvt:pointDataLayer>
                </dvt:thematicMap>
            </f:facet>
            <f:facet name="header"/>
            <f:facet name="end"/>
            <f:facet name="start">
                <af:inputText label="Address" id="it2" binding="#{viewScope.LLConverter.addressBind}">
                </af:inputText>
                <af:button text= "GetLocation" id="b1"
                           actionListener="#{AddButton.addLocation}"/>
            </f:facet>
            <f:facet name="branding"/>
            <f:facet name="copyright"/>
            <f:facet name="status"/>
        </af:pageTemplate>
    </af:form>
</af:document>

Addbutton是我给bean起的名字,它的类是LLConverter,方法是addLocation。我尝试过无数次重命名和创建bean,并尝试了不同的作用域(这里没有,但我尝试过查看和请求作用域)

我只是不断得到同样的错误,“找不到引用addLocation”

这个错误允许我自动将适当的方法生成到LLConverter类中,但是当我将代码放入该方法中时,它再次给了我错误。这让我相信可能是类代码,而不是方法绑定

非常感谢您的任何想法和想法!当然,我肯定我错过了一些必要的信息,所以请立即询问


谢谢,您的actionListener只能将ActionEvent作为参数(因此请删除所有其他内容)。 如果要发送额外参数,可以使用以下逻辑:

在页面上:

<af:button text="button" id="cb1"
                  actionListener="#{myBean.myActionListener}">
  <f:attribute name="param" value="value"/>
</af:button>

您当然可以使用您的绑定。

嘿,既然您熟悉我的代码,我还有一个问题。当然,如果您想让我在新问题中再次问这个问题,我非常愿意。我的jsf页面的pointX和pointY也会抛出错误。它们说“未找到行.纬度”和“行.经度”找不到。我找不到很多关于地图这一功能的文档,但从我所看到的来看,这是应该怎么写的。但我可能是100%地做错了。Thanks@MMM我不太熟悉dvt组件,所以最好问一个新问题。
<af:button text="button" id="cb1"
                  actionListener="#{myBean.myActionListener}">
  <f:attribute name="param" value="value"/>
</af:button>
public void myActionListener(ActionEvent actionEvent) {
  String param = (String)actionEvent.getComponent().getAttributes().get("param");
}