Kevin Rapter

Greenhorn
+ Follow
since Jul 28, 2016
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kevin Rapter

Kevin Rapter wrote:Hi,

I have an issue about the exception based on casting to $Proxy5.

I designed a worker class in model package and connect it via springcfg.xml defining beans. Iwant to show a message for checking whether proxyfactorybean works or not before calling object's functions.

When I run the code, it throw a message shown below.



The line the message is thrown is shown below.




Moreover, I want to show my springcfg.xml.

Here it is.

      

How can I fix the problem?

I use Spring 5.1.0.RELEASE version.

Thank you.






1 month ago
Hi,

I have an issue about the exception based on casting to $Proxy5.

I designed a worker class in model package and connect it via springcfg.xml defining beans. Iwant to show a message for checking whether proxyfactorybean works or not before calling object's functions.

When I run the code, it throw a message shown below.



The line the message is thrown is shown below.




Moreover, I want to show my springcfg.xml.

Here it is.

      

How can I fix the problem?

I use Spring 5.1.0.RELEASE version.

Thank you.






1 month ago
Hi,

I have an issue about showing buttonImage of keyboard tag. I think it can be directly caused from the wrong defination of image source path.

I put the image in the directory and the path of image is shown below.

WebContent / resources / images / keyboardpencil.png.

In my sample.xhtml , the image can not shown . Here is below.

<hutputText value="Image Mode: " />
<p:keyboard value="#{keyboardBean.value8}" showMode="button"
buttonImageOnly="true" buttonImage="resources/images/keyboardpencil.png"
keypadOnly="true" />

How can I solve it out?

Thank you.
9 months ago
Norm Radder

I already knew that there is an arrayoutofboundsException because of the size of array before I post it here. My Question is how to troubleshoot it .
1 year ago
I sent the position of each item of gridview to next activity. When I pressed first one, content realted with it was listed but when I pressed other positions such as 2nd 3th and son on , app was crushed.When I run the app the debug mode, I show that the position is got from Adapter but I couldn't solve the issue. How do I solve it out? Thanks.

Here are the codes belows.

MainActivity

gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
               switch (position){

               case 0:
                    Toast.makeText(getApplicationContext(),position+"",Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(MainActivity.this,AttactivePlacesActivity.class);
                    intent.putExtra("position",position);
                    startActivity(intent);
                    break;

                case 1:
                    Toast.makeText(getApplicationContext(),position+"",Toast.LENGTH_SHORT).show();
                    Intent intent1 = new Intent(MainActivity.this,AttactivePlacesActivity.class);
                    intent1.putExtra("position",position);
                    startActivity(intent1);
                    break;
AttactivePlacesActivity

Intent mIntent = getIntent();
        Bundle bundle = mIntent.getExtras();

        int position = bundle.getInt("position");



        AttractivePlacesAdapter attractivePlacesAdapter = new AttractivePlacesAdapter(this,cityAttactivePlaces,R.color.mainBackground,position);
AttractivePlacesAdapter

public class AttractivePlacesAdapter extends ArrayAdapter<City> {

    private int mBackgroundColor; // BackGround Color For each Activity

    private int gridviewPosition;

    public AttractivePlacesAdapter(Context context, ArrayList<City> resources, int color,int position) {
        // Here, we initialize the ArrayAdapter's internal storage for the context and the list.
        // the second argument is used when the ArrayAdapter is populating a single TextView.
        // Because this is a custom adapter for two TextViews , the adapter is not
        // going to use this second argument, so it can be any value. Here, we used 0.
        // 0 -> list item layout resource ID
        super(context,0 ,resources);
        mBackgroundColor = color;
        gridviewPosition = position;
    }


    // get list item from getView

    /**
     * Provides a view for an AdapterView (ListView, GridView, etc.)
     *
     * @param position The position in the list of data that should be displayed in the
     *                 list item view.
     * @param convertView The recycled view to populate.
     * @param parent The parent ViewGroup that is used for inflation.
     * @return The View for the position in the AdapterView.
     */
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        // Check if the existing view is being reused, otherwise inflate the view
        View listview = convertView;
        if (listview == null) {
            // parent -> listView   false -> we don't want to attach list item to parent
            listview = LayoutInflater.from(getContext()).inflate(R.layout.layout, parent, false);
        }

        // get position of item to city
        City city = getItem(gridviewPosition);


            // City Information
            TextView name = (TextView) listview.findViewById(R.id.bilgi_text_view);
            name.setText(city.getAttactivePlaces().get(position).getPlaceName());


            // Picture of City
            ImageView image = (ImageView) listview.findViewById(R.id.image_image_view);


            // Check whether the picture is or not.
            if (city.hasImage()) {
                //
               image.setImageResource(city.getAttactivePlaces().get(position).getmAttaticePlaceImageResourceId());
            } else {
                image.setVisibility(View.GONE);
            }

        //}

        // Set theme color for the list item
        View textContainer = listview.findViewById(R.id.text_container);

        // Find the color that the resource ID maps to
        int color = ContextCompat.getColor(getContext(), mBackgroundColor);

        // Set Background color to view
        textContainer.setBackgroundColor(color);

        return listview;

    }

}


Error

03-12 09:52:35.417 5056-5056/com.example.android.turkeytourguide E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                   Process: com.example.android.turkeytourguide, PID: 5056
                                                                                   java.lang.IndexOutOfBoundsException: Invalid index 1, size is 1
                                                                                       at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
                                                                                       at java.util.ArrayList.get(ArrayList.java:308)
                                                                                       at com.example.android.turkeytourguide.AttractivePlacesAdapter.getView(AttractivePlacesAdapter.java:63)
                                                                                       at android.widget.AbsListView.obtainView(AbsListView.java:2344)
                                                                                       at android.widget.ListView.makeAndAddView(ListView.java:1864)
                                                                                       at android.widget.ListView.fillDown(ListView.java:698)
                                                                                       at android.widget.ListView.fillFromTop(ListView.java:759)
                                                                                       at android.widget.ListView.layoutChildren(ListView.java:1673)
                                                                                       at android.widget.AbsListView.onLayout(AbsListView.java:2148)
                                                                                       at android.view.View.layout(View.java:15596)
                                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4966)
                                                                                       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
                                                                                       at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
                                                                                       at android.view.View.layout(View.java:15596)
                                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4966)
                                                                                       at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437)
                                                                                       at android.view.View.layout(View.java:15596)
                                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4966)
                                                                                       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
                                                                                       at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
                                                                                       at android.view.View.layout(View.java:15596)
                                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4966)
                                                                                       at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
                                                                                       at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
                                                                                       at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
                                                                                       at android.view.View.layout(View.java:15596)
                                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4966)
                                                                                       at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
                                                                                       at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
                                                                                       at android.view.View.layout(View.java:15596)
                                                                                       at android.view.ViewGroup.layout(ViewGroup.java:4966)
                                                                                       at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2072)
                                                                                       at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1829)
                                                                                       at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
                                                                                       at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
                                                                                       at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
                                                                                       at android.view.Choreographer.doCallbacks(Choreographer.java:580)
                                                                                       at android.view.Choreographer.doFrame(Choreographer.java:550)
                                                                                       at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
                                                                                       at android.os.Handler.handleCallback(Handler.java:739)
                                                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                       at android.os.Looper.loop(Looper.java:135)
                                                                                       at android.app.ActivityThread.main(ActivityThread.java:5223)
                                                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)


Error line --> name.setText(city.getAttactivePlaces().get(position).getPlaceName());

1 year ago
I just created a city object with other essential things like tourist places. I used arraylist in the Arraylist .

There is any object in the arrayslist .Here is the code below.

City city = new City();

        city.setCityName("London");
        city.setmCityImageResourceId(R.drawable.london);

        AttactivePlaces londonAttactivePlaces_one =new AttactivePlaces();
        londonAttactivePlaces_one.setPlaceName("Big Ben");
        londonAttactivePlaces_one.setmAttaticePlaceImageResourceId(R.drawable.bigben);
        londonAttactivePlaces_one.setPlaceDetailInformation("Big Ben");
        city.getAttactivePlaces().add(londonAttactivePlaces_one);


MainActicity

CityAdapter cityAdapter = new CityAdapter(this,cityArraylist,R.color.mainBackground);

        GridView gridView = (GridView) findViewById(R.id.gridlist);
        gridView.setAdapter(cityAdapter);

        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {

                switch (position){

                    case 0:
                        //Toast.makeText(getApplicationContext(),"─░stanbul",Toast.LENGTH_SHORT).show();
                        Toast.makeText(getApplicationContext(),position+"",Toast.LENGTH_SHORT).show();
                        Intent intent = new Intent(MainActivity.this,AttactivePlacesActivity.class);
                        intent.putExtra("position_griditem_one",position);
                        startActivity(intent);
                        break;

AttractivePalcesActivity

ArrayList<City> cityAttactivePlaces = new ArrayList<City>();

      
        cityAttactivePlaces = MainActivity.cityArraylist;

        AttractivePlacesAdapter attractivePlacesAdapter = new AttractivePlacesAdapter(this,cityAttactivePlaces,R.color.mainBackground);

        ListView listView = (ListView) findViewById(R.id.listviewAttactivePlaces);

        listView.setAdapter(attractivePlacesAdapter);


AttractivePlacesAdapter

public class AttractivePlacesAdapter extends ArrayAdapter<City> {

    private int mBackgroundColor; // BackGround Color For each Activity


    public AttractivePlacesAdapter(Context context, ArrayList<City> resources, int color) {
        // Here, we initialize the ArrayAdapter's internal storage for the context and the list.
        // the second argument is used when the ArrayAdapter is populating a single TextView.
        // Because this is a custom adapter for two TextViews , the adapter is not
        // going to use this second argument, so it can be any value. Here, we used 0.
        // 0 -> list item layout resource ID
        super(context,0 ,resources);
        mBackgroundColor = color;
    }


    // get list item from getView

    /**
     * Provides a view for an AdapterView (ListView, GridView, etc.)
     *
     * @param position The position in the list of data that should be displayed in the
     *                 list item view.
     * @param convertView The recycled view to populate.
     * @param parent The parent ViewGroup that is used for inflation.
     * @return The View for the position in the AdapterView.
     */
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        // Check if the existing view is being reused, otherwise inflate the view
        View listview = convertView;
        if (listview == null) {
            // parent -> listView   false -> we don't want to attach list item to parent
            listview = LayoutInflater.from(getContext()).inflate(R.layout.layout, parent, false);
        }

        // get position of item to city
        //City city = getItem(position);

        ArrayList<City> cityArrayList = MainActivity.cityArraylist;

        City city = cityArrayList.get(1);

        for(int i=0;i<city.getAttactivePlaces().size();i++){

            // City Information
            TextView name = (TextView) listview.findViewById(R.id.bilgi_text_view);
            name.setText(city.getAttactivePlaces().get(i).getPlaceName());


            // Picture of City
            ImageView image = (ImageView) listview.findViewById(R.id.image_image_view);

            // Check whether the picture is or not.
            if (city.hasImage()) {
                //
                image.setImageResource(city.getAttactivePlaces().get(i).getmAttaticePlaceImageResourceId());
            } else {
                image.setVisibility(View.GONE);
            }

        }

        // City Information
        //TextView name = (TextView) listview.findViewById(R.id.name);

        //name.setText(city.getAttactivePlaces().get(0).getPlaceName());

        //city.getAttactivePlaces().get(position).getPlaceName()

        // Picture of City
        //ImageView image = (ImageView) listview.findViewById(R.id.image_image_view);

        // Check whether the picture is or not.
        //if (city.hasImage()) {
            //
        //    image.setImageResource(city.getAttactivePlaces().get(0).getmAttaticePlaceImageResourceId());
        //} else {
        //   image.setVisibility(View.GONE);
        //}


        // Set theme color for the list item
        View textContainer = listview.findViewById(R.id.text_container);

        // Find the color that the resource ID maps to
        int color = ContextCompat.getColor(getContext(), mBackgroundColor);

        // Set Background color to view
        textContainer.setBackgroundColor(color);

        return listview;

    }

}

When I clicked any item of gridview, list informaiton of this item.  I ask it to many platform but not required response is occured.

How do I access clicked item' position  of gridview form AttractivePlacesAdapter.

I will apprecate you if you answer my quesiton and show the solution step by step.
1 year ago
I tried action="#{subCategoryMB.addSubCategory} but nothing changed.
2 years ago
JSF
I devised a sample category with subcategory module in jsf by eclipse. I made an adding category module without any issue but I couldn't make an adding subcategory under related category .  Here the code below.

Suncategory .xhtml



<h:form>

    <p:panelGrid columns="2">

        <h:outputLabel value="Category Name></h:outputLabel>

        <p:selectOneMenu value="#{subCategoryMB.categoryName}">
            <f:selectItem itemLabel="Select Category" itemValue=""></f:selectItem>
            <f:selectItems value="#{subCategoryMB.categorylist}" />
        </p:selectOneMenu>

        <h:outputLabel value="Category Name"></h:outputLabel>
        <p:inputText value="#{subCategoryMB.subcategory.subName}"></p:inputText>

        <h:outputLabel value="Category Description"></h:outputLabel>
        <p:inputText value="#{subCategoryMB.subcategory.subNameDes}"></p:inputText>

        <h:commandButton value="Add Subcategory" action="#{subCategoryMB.addSubCategory()}"></h:commandButton>


    </p:panelGrid>


</h:form>
</h:body



Category Dao

public List getAllcategoriesbyName(String name) {
// TODO Auto-generated method stub
Session session = HibernateUtil.getSessionFactory().openSession();

    try {

        List<Category> liste = session.createQuery("from Category C where name='"+name+"'").list();
        return liste;


    } catch (Exception e) {
        e.printStackTrace();

    }finally {

        session.close();

    }
    return null;
}

public List<Category> getAllcategoriesSelectItemName() {
// TODO Auto-generated method stub
Session session = HibernateUtil.getSessionFactory().openSession();

try {

List<Category> liste = session.createQuery("Select C.name from Category C").list();

return liste;


} catch (Exception e) {
e.printStackTrace();

}finally {

session.close();

}
return null;
}


SubCategoryMB


public class SubCategoryMB {

SubCategory subcategory = new SubCategory();

private String categoryName;
private List<Category> categorylist;
private List<SubCategory> subCategoryList;
private Category category= new Category();

public SubCategoryMB() {
    // TODO Auto-generated constructor stub
}

public SubCategory getSubcategory() {
    return subcategory;
}

public void setSubcategory(SubCategory subcategory) {
    this.subcategory = subcategory;
}

public List<Category> getCategorylist() {
    CategoryDAO cDao = new CategoryDAO();
    this.categorylist= cDao.getAllcategoriesSelectItemName();
    return categorylist;
}

public void setCategorylist(List<Category> categorylist) {
    this.categorylist = categorylist;
}


public String getCategoryName() {
    return categoryName;
}

public void setCategoryName(String categoryName) {
    this.categoryName = categoryName;
}


public Category getCategory() {
    return category;
}

public void setCategory(Category category) {
    this.category = category;
}


public List<SubCategory> getSubCategoryList() {
    SubCategoryDAO subDao = new SubCategoryDAO();
    this.subCategoryList= subDao.getAllSubcategories();
    return subCategoryList;
}

public void addSubCategory(){

           // ISSUE
                categorylistbySubCategory= new CategoryDAO().getAllcategoriesbyName(categoryName);
category.setId(categorylistbySubCategory.get(0).getId());
subcategory.setCategory(category);
subcategory.setSubName(subcategory.getSubName());
subcategory.setSubNameDes(subcategory.getSubNameDes());
new SubCategoryDAO().addSubCategory(subcategory);
}
}

There is a problem about addSubCategory(). I can't add subcategory to its category.
2 years ago
JSF