Androidでjsfフォームデータを投稿できますか?たとえば、このjsfページ;
<h:form>
<h:panelGrid columns="2" border="0">
<h:outputLabel value="Adınız : "/>
<h:inputText value="#{pd.ad}"/>
<h:outputLabel value=""/>
<h:commandButton value="Gönder" action="#{pd.kontrol()}"/>
</h:panelGrid>
</h:form>
<h:outputText value="#{pd.sonuc}" />
「広告」データを Android に投稿したいのですが、私の Android コードは次のとおりです。
private TextView postData;
private String url = "http://localhost:8084/AndroidIc_nPOSTsayfa";
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT >= 9) {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
postData = (TextView)findViewById(R.id.postData);
try {
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("#{pd.sonuc}", "Mesut Emre"));
httpPost.setEntity(new UrlEncodedFormEntity(pairs));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String response = httpClient.execute(httpPost,responseHandler);
System.out.println(response);
postData.setText("Alınan veri:"+response);
} catch (Exception e) {
e.printStackTrace();
}
}
アプリを実行するとエラーは発生しませんが、送信したデータがテキストビューに表示されません。