Package org.jivesoftware.smackx.packet

Examples of org.jivesoftware.smackx.packet.DataForm


                        }
                    }
                } else if (elementName.equals("feature")) {
                } else if (elementName.equals("x") && namespace.equals("jabber:x:data")) {
                    DataFormProvider dataFormProvider = new DataFormProvider();
                    DataForm dataForm = (DataForm)dataFormProvider.parseExtension(parser);
                    feature = new StreamInitiation.Feature(dataForm.getType());
                    feature.setDataForm(dataForm);
                }
            } else if (eventType == XmlPullParser.END_TAG && elementName.equals("si")) {
                done = true;
            }
View Full Code Here


  private void showResults( SearchIQ results ){
    Hashtable<String,String> columns = new Hashtable<String,String>();
    Vector<Object> rowData = new Vector<Object>();
    Iterator extensions = results.getExtensions();
    while( extensions.hasNext() ){
      DataForm dataForm = (DataForm)extensions.next();
      ReportedData rData = dataForm.getReportedData();
      Iterator fields = rData.getFields();
      while( fields.hasNext() ){
        FormField fField = (FormField)fields.next();
        columns.put( fField.getVariable(), fField.getLabel() );
      }
     
      Iterator items = dataForm.getItems();
      while( items.hasNext() ){
        DataForm.Item item = (DataForm.Item)items.next();
        int a = 0;
        String [] strArray = new String[ columns.size() ];
        Iterator field = item.getFields();
View Full Code Here

            Packet response = client.sendSync(requestCommand);
           
            StringBuffer htmlForm = new StringBuffer();
            if(response != null) {
                AdHocCommandData responseData = (AdHocCommandData) response;
                DataForm form = responseData.getForm();
               
                for(AdHocCommandNote note : responseData.getNotes()) {
                    htmlForm.append("<p class='note " + note.getType() + "'>" + note.getValue() + "</p>");
                }
               
                htmlForm.append("<form action='' method='post'>");
                htmlForm.append("<input type='hidden' name='" + SESSION_FIELD + "' value='" + responseData.getSessionID() + "' />");
   
                htmlForm.append(htmlFormBuilder.build(form));
                if(Status.executing.equals(responseData.getStatus())) {
                    htmlForm.append("<input type='submit' value='" + COMMANDS.get(command) + "' />");
                } else if(Status.completed.equals(responseData.getStatus())) {
                    if(form == null || form.getFields() == null || !form.getFields().hasNext()) {
                        // no field, print success
                        htmlForm.append("<p>Command successful</p>");
                    }
                }
                htmlForm.append("</form>");
View Full Code Here

     */
    public AdHocCommandData build(Map<String, String[]> parameters) {
        AdHocCommandData commandData = new AdHocCommandData();
        commandData.setSessionID(getSingleValue(parameters, AdminConsoleController.SESSION_FIELD));
       
        DataForm form = new DataForm("submit");
       
        for(Entry<String, String[]> entry : parameters.entrySet()) {
            if(!AdminConsoleController.SESSION_FIELD.equals(entry.getKey())) {
                FormField field = new FormField(entry.getKey());
                for(String value : entry.getValue()) {
                    String[] splitValues = value.split("[\\r\\n]+");
                    for(String splitValue : splitValues) {
                        field.addValue(splitValue);
                    }
                }
                form.addField(field);
            }
        }
       
        commandData.setForm(form);
       
View Full Code Here

    public static ReportedData getReportedDataFrom(Packet packet) {
        // Check if the packet includes the DataForm extension
        PacketExtension packetExtension = packet.getExtension("x","jabber:x:data");
        if (packetExtension != null) {
            // Check if the existing DataForm is a result of a search
            DataForm dataForm = (DataForm) packetExtension;
            if (dataForm.getReportedData() != null)
                return new ReportedData(dataForm);
        }
        // Otherwise return null
        return null;
    }
View Full Code Here

    public static Form getFormFrom(Packet packet) {
        // Check if the packet includes the DataForm extension
        PacketExtension packetExtension = packet.getExtension("x","jabber:x:data");
        if (packetExtension != null) {
            // Check if the existing DataForm is not a result of a search
            DataForm dataForm = (DataForm) packetExtension;
            if (dataForm.getReportedData() == null)
                return new Form(dataForm);
        }
        // Otherwise return null
        return null;
    }
View Full Code Here

     * </ul>
     *
     * @param type the form's type (e.g. form, submit,cancel,result).
     */
    public Form(String type) {
        this.dataForm = new DataForm(type);
    }
View Full Code Here

     * @return the wrapped DataForm.
     */
    public DataForm getDataFormToSend() {
        if (isSubmitType()) {
            // Create a new DataForm that contains only the answered fields
            DataForm dataFormToSend = new DataForm(getType());
            for(Iterator<FormField> it=getFields();it.hasNext();) {
                FormField field = it.next();
                if (field.getValues().hasNext()) {
                    dataFormToSend.addField(field);
                }
            }
            return dataFormToSend;
        }
        return dataForm;
View Full Code Here

            return simpleUserSearch;
        }
    }

    private static void buildDataForm(SimpleUserSearch search, String instructions, XmlPullParser parser) throws Exception {
        DataForm dataForm = new DataForm(Form.TYPE_FORM);
        boolean done = false;
        dataForm.setTitle("User Search");
        dataForm.addInstruction(instructions);
        while (!done) {
            int eventType = parser.next();

            if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) {
                String name = parser.getName();
                FormField field = new FormField(name);

                // Handle hard coded values.
                if(name.equals("first")){
                    field.setLabel("First Name");
                }
                else if(name.equals("last")){
                    field.setLabel("Last Name");
                }
                else if(name.equals("email")){
                    field.setLabel("Email Address");
                }
                else if(name.equals("nick")){
                    field.setLabel("Nickname");
                }

                field.setType(FormField.TYPE_TEXT_SINGLE);
                dataForm.addField(field);
            }
            else if (eventType == XmlPullParser.END_TAG) {
                if (parser.getName().equals("query")) {
                    done = true;
                }
View Full Code Here

public class RoomInfoTest
{
    @Test
    public void validateRoomWithEmptyForm()
    {
  DataForm dataForm = new DataForm("result");
 
  DiscoverInfo discoInfo = new DiscoverInfo();
  discoInfo.addExtension(dataForm);
  RoomInfo roomInfo = new RoomInfo(discoInfo);
  assertTrue(roomInfo.getDescription().isEmpty());
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.packet.DataForm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.