You need to sign in to do that
Don't have an account?
Unable to get the values in Vf page
Hi all,
My vf page and class is as below
<apex:page controller="XmlStreamDemo">
<apex:form >
<apex:commandButton value="Refer" action="{!refer}"/>
<apex:outputText value="{!socialnetwork}"></apex:outputText>
</apex:form>
</apex:page>
-----------------------------------------------------------------------------------------
public class XmlStreamDemo {
public string link{get;set;}
public String socialnetwork { get; set; }
public class Network{
String name;
String Image;
}
Network[] parseNetworks(XmlStreamReader reader) {
Network[] socialnetwork = new Network[0];
while(reader.hasNext()) {
if (reader.getEventType() == XmlTag.START_ELEMENT) {
if ('Network' == reader.getLocalName()) {
Network link = parseNetwork(reader);
socialnetwork.add(link);
}
}
reader.next();
}
return socialnetwork;
}
Network parseNetwork(XmlStreamReader reader) {
Network link = new Network();
link.Image = reader.getAttributeValue(null, 'Image');
while(reader.hasNext()) {
if (reader.getEventType() == XmlTag.END_ELEMENT) {
break;
} else if (reader.getEventType() == XmlTag.CHARACTERS) {
link.name = reader.getText();
}
reader.next();
}
return link;
}
Public void refer() {
XmlStreamDemo demo = new XmlStreamDemo();
String str = '<socialnetwork><link Image="Chatty">Aruna</link>' +
'<link Image="Sassy">Baz</link></socialnetwork>';
XmlStreamReader reader2 = new XmlStreamReader(str);
Network[] socialnetwork= demo.parseNetworks(reader2);
System.debug('======'+socialnetwork.size());
// System.debug('==========='+socialnetwork);
for (Network Image:socialnetwork1 ) {
System.debug('-------'+Image);
}
}
}
here the problem is Im unable to get the values in outputtext and whenever Im checking in debug it's showing the size as 0......Any reply would be greatly appreciated
Thanks in advance
HI,
Use rerender inside the apex:command button .
Try the below code snippet as refenence:
<apex:page controller="XmlStreamDemo">
<apex:form id=”fo”>
<apex:commandButton value="Refer" action="{!refer}" rerender=”fo”/>
<apex:outputpanel id=”op”>
<apex:outputText value="{!socialnetwork}"></apex:outputText>
</apex:outputpane l>
</apex:form>
</apex:page>
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
Error: XmlStreamDemo Compile Error: The property String socialnetwork1 is referenced by Visualforce Page (xxx) in salesforce.com. Remove the usage and try again. at line 3 column 19
getting this error.....dnt know why?